├── .gitignore ├── README.md ├── ajaxCall.html ├── ajaxCall.js ├── api ├── category │ ├── create.php │ ├── delete.php │ ├── read.php │ ├── read_single.php │ └── update.php └── post │ ├── create.php │ ├── delete.php │ ├── read.php │ ├── read_single.php │ └── update.php ├── config └── Database.php ├── models ├── Category.php └── Post.php └── myblog.sql /.gitignore: -------------------------------------------------------------------------------- 1 | jtest.js -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PHP REST API 2 | 3 | > This is a simple PHP REST API from scratch with no framework. 4 | 5 | ## Quick Start 6 | 7 | Import the myblog.sql file, change the params in the config/Database.php file to your own 8 | 9 | ## App Info 10 | 11 | ### Author 12 | 13 | Brad Traversy 14 | [Traversy Media](http://www.traversymedia.com) 15 | 16 | ### Version 17 | 18 | 1.0.0 19 | 20 | ### License 21 | 22 | This project is licensed under the MIT License 23 | -------------------------------------------------------------------------------- /ajaxCall.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 9 | 10 | 11 | 37 | 38 | 39 | 40 |
41 |

Data Finder

42 |

The message will go here

43 |

44 |
45 | 46 | 47 |
48 |

Data Sender

49 |
50 | 51 |
52 |
53 |
54 |

55 | 56 | 57 |
58 |
59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /ajaxCall.js: -------------------------------------------------------------------------------- 1 | 2 | //POST REQUEST 3 | 4 | $(document).ready(function(){ 5 | $('#postMessage').click(function(e){ 6 | e.preventDefault(); 7 | 8 | //serialize form data 9 | var url = $('form').serialize(); 10 | 11 | //function to turn url to an object 12 | function getUrlVars(url) { 13 | var hash; 14 | var myJson = {}; 15 | var hashes = url.slice(url.indexOf('?') + 1).split('&'); 16 | for (var i = 0; i < hashes.length; i++) { 17 | hash = hashes[i].split('='); 18 | myJson[hash[0]] = hash[1]; 19 | } 20 | return JSON.stringify(myJson); 21 | } 22 | 23 | //pass serialized data to function 24 | var test = getUrlVars(url); 25 | 26 | //post with ajax 27 | $.ajax({ 28 | type:"POST", 29 | url: "/Work folders/OOP php/RESTFUL traversy/php_rest_myblog/api/post/create.php", 30 | data: test, 31 | ContentType:"application/json", 32 | 33 | success:function(){ 34 | alert('successfully posted'); 35 | }, 36 | error:function(){ 37 | alert('Could not be posted'); 38 | } 39 | 40 | }); 41 | }); 42 | }); 43 | 44 | 45 | //GET REQUEST 46 | 47 | document.addEventListener('DOMContentLoaded',function(){ 48 | document.getElementById('getMessage').onclick=function(){ 49 | 50 | var req; 51 | req=new XMLHttpRequest(); 52 | req.open("GET", '/Work folders/OOP php/RESTFUL traversy/php_rest_myblog/api/post/read.php',true); 53 | req.send(); 54 | 55 | req.onload=function(){ 56 | var json=JSON.parse(req.responseText); 57 | 58 | //limit data called 59 | var son = json.filter(function(val) { 60 | return (val.id >= 4); 61 | }); 62 | 63 | var html = ""; 64 | 65 | //loop and display data 66 | son.forEach(function(val) { 67 | var keys = Object.keys(val); 68 | 69 | html += "
"; 70 | keys.forEach(function(key) { 71 | html += "" + key + ": " + val[key] + "
"; 72 | }); 73 | html += "

"; 74 | }); 75 | 76 | //append in message class 77 | document.getElementsByClassName('message')[0].innerHTML=html; 78 | }; 79 | }; 80 | }); 81 | 82 | -------------------------------------------------------------------------------- /api/category/create.php: -------------------------------------------------------------------------------- 1 | connect(); 13 | 14 | // Instantiate blog post object 15 | $category = new Category($db); 16 | 17 | // Get raw posted data 18 | $data = json_decode(file_get_contents("php://input")); 19 | 20 | $category->name = $data->name; 21 | 22 | // Create Category 23 | if($category->create()) { 24 | echo json_encode( 25 | array('message' => 'Category Created') 26 | ); 27 | } else { 28 | echo json_encode( 29 | array('message' => 'Category Not Created') 30 | ); 31 | } 32 | -------------------------------------------------------------------------------- /api/category/delete.php: -------------------------------------------------------------------------------- 1 | connect(); 13 | 14 | // Instantiate blog post object 15 | $category = new Category($db); 16 | 17 | // Get raw posted data 18 | $data = json_decode(file_get_contents("php://input")); 19 | 20 | // Set ID to UPDATE 21 | $category->id = $data->id; 22 | 23 | // Delete post 24 | if($category->delete()) { 25 | echo json_encode( 26 | array('message' => 'Category deleted') 27 | ); 28 | } else { 29 | echo json_encode( 30 | array('message' => 'Category not deleted') 31 | ); 32 | } 33 | -------------------------------------------------------------------------------- /api/category/read.php: -------------------------------------------------------------------------------- 1 | connect(); 12 | 13 | // Instantiate category object 14 | $category = new Category($db); 15 | 16 | // Category read query 17 | $result = $category->read(); 18 | 19 | // Get row count 20 | $num = $result->rowCount(); 21 | 22 | // Check if any categories 23 | if($num > 0) { 24 | // Cat array 25 | $cat_arr = array(); 26 | $cat_arr['data'] = array(); 27 | 28 | while($row = $result->fetch(PDO::FETCH_ASSOC)) { 29 | extract($row); 30 | 31 | $cat_item = array( 32 | 'id' => $id, 33 | 'name' => $name 34 | ); 35 | 36 | // Push to "data" 37 | array_push($cat_arr['data'], $cat_item); 38 | } 39 | 40 | // Turn to JSON & output 41 | echo json_encode($cat_arr); 42 | 43 | } else { 44 | // No Categories 45 | echo json_encode( 46 | array('message' => 'No Categories Found') 47 | ); 48 | } 49 | -------------------------------------------------------------------------------- /api/category/read_single.php: -------------------------------------------------------------------------------- 1 | connect(); 12 | // Instantiate blog category object 13 | $category = new Category($db); 14 | 15 | // Get ID 16 | $category->id = isset($_GET['id']) ? $_GET['id'] : die(); 17 | 18 | // Get post 19 | $category->read_single(); 20 | 21 | // Create array 22 | $category_arr = array( 23 | 'id' => $category->id, 24 | 'name' => $category->name 25 | ); 26 | 27 | // Make JSON 28 | print_r(json_encode($category_arr)); 29 | -------------------------------------------------------------------------------- /api/category/update.php: -------------------------------------------------------------------------------- 1 | connect(); 13 | 14 | // Instantiate blog post object 15 | $category = new Category($db); 16 | 17 | // Get raw posted data 18 | $data = json_decode(file_get_contents("php://input")); 19 | 20 | // Set ID to UPDATE 21 | $category->id = $data->id; 22 | 23 | $category->name = $data->name; 24 | 25 | // Update post 26 | if($category->update()) { 27 | echo json_encode( 28 | array('message' => 'Category Updated') 29 | ); 30 | } else { 31 | echo json_encode( 32 | array('message' => 'Category not updated') 33 | ); 34 | } 35 | -------------------------------------------------------------------------------- /api/post/create.php: -------------------------------------------------------------------------------- 1 | connect(); 14 | 15 | // Instantiate blog post object 16 | $post = new Post($db); 17 | 18 | // Get raw posted data 19 | $data = json_decode(file_get_contents("php://input")); 20 | 21 | $post->title = $data->title; 22 | $post->body = $data->body; 23 | $post->author = $data->author; 24 | $post->category_id = $data->category_id; 25 | 26 | // Create post 27 | if($post->create()) { 28 | echo json_encode( 29 | array('message' => 'Post Created') 30 | ); 31 | } else { 32 | echo json_encode( 33 | array('message' => 'Post Not Created') 34 | ); 35 | } 36 | 37 | -------------------------------------------------------------------------------- /api/post/delete.php: -------------------------------------------------------------------------------- 1 | connect(); 14 | 15 | // Instantiate blog post object 16 | $post = new Post($db); 17 | 18 | // Get raw posted data 19 | $data = json_decode(file_get_contents("php://input")); 20 | 21 | // Set ID to update 22 | $post->id = $data->id; 23 | 24 | // Delete post 25 | if($post->delete()) { 26 | echo json_encode( 27 | array('message' => 'Post Deleted') 28 | ); 29 | } else { 30 | echo json_encode( 31 | array('message' => 'Post Not Deleted') 32 | ); 33 | } 34 | 35 | -------------------------------------------------------------------------------- /api/post/read.php: -------------------------------------------------------------------------------- 1 | connect(); 12 | 13 | // Instantiate blog post object 14 | $post = new Post($db); 15 | 16 | // Blog post query 17 | $result = $post->read(); 18 | // Get row count 19 | $num = $result->rowCount(); 20 | 21 | // Check if any posts 22 | if($num > 0) { 23 | // Post array 24 | $posts_arr = array(); 25 | // $posts_arr['data'] = array(); 26 | 27 | while($row = $result->fetch(PDO::FETCH_ASSOC)) { 28 | extract($row); 29 | 30 | $post_item = array( 31 | 'id' => $id, 32 | 'title' => $title, 33 | 'body' => html_entity_decode($body), 34 | 'author' => $author, 35 | 'category_id' => $category_id, 36 | 'category_name' => $category_name 37 | ); 38 | 39 | // Push to "data" 40 | array_push($posts_arr, $post_item); 41 | // array_push($posts_arr['data'], $post_item); 42 | } 43 | 44 | // Turn to JSON & output 45 | echo json_encode($posts_arr); 46 | 47 | } else { 48 | // No Posts 49 | echo json_encode( 50 | array('message' => 'No Posts Found') 51 | ); 52 | } 53 | -------------------------------------------------------------------------------- /api/post/read_single.php: -------------------------------------------------------------------------------- 1 | connect(); 12 | 13 | // Instantiate blog post object 14 | $post = new Post($db); 15 | 16 | // Get ID 17 | $post->id = isset($_GET['id']) ? $_GET['id'] : die(); 18 | 19 | // Get post 20 | $post->read_single(); 21 | 22 | // Create array 23 | $post_arr = array( 24 | 'id' => $post->id, 25 | 'title' => $post->title, 26 | 'body' => $post->body, 27 | 'author' => $post->author, 28 | 'category_id' => $post->category_id, 29 | 'category_name' => $post->category_name 30 | ); 31 | 32 | // Make JSON 33 | print_r(json_encode($post_arr)); -------------------------------------------------------------------------------- /api/post/update.php: -------------------------------------------------------------------------------- 1 | connect(); 14 | 15 | // Instantiate blog post object 16 | $post = new Post($db); 17 | 18 | // Get raw posted data 19 | $data = json_decode(file_get_contents("php://input")); 20 | 21 | // Set ID to update 22 | $post->id = $data->id; 23 | 24 | $post->title = $data->title; 25 | $post->body = $data->body; 26 | $post->author = $data->author; 27 | $post->category_id = $data->category_id; 28 | 29 | // Update post 30 | if($post->update()) { 31 | echo json_encode( 32 | array('message' => 'Post Updated') 33 | ); 34 | } else { 35 | echo json_encode( 36 | array('message' => 'Post Not Updated') 37 | ); 38 | } 39 | 40 | -------------------------------------------------------------------------------- /config/Database.php: -------------------------------------------------------------------------------- 1 | conn = null; 13 | 14 | try { 15 | $this->conn = new PDO('mysql:host=' . $this->host . ';dbname=' . $this->db_name, $this->username, $this->password); 16 | $this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); 17 | } catch(PDOException $e) { 18 | echo 'Connection Error: ' . $e->getMessage(); 19 | } 20 | 21 | return $this->conn; 22 | } 23 | } -------------------------------------------------------------------------------- /models/Category.php: -------------------------------------------------------------------------------- 1 | conn = $db; 15 | } 16 | 17 | // Get categories 18 | public function read() { 19 | // Create query 20 | $query = 'SELECT 21 | id, 22 | name, 23 | created_at 24 | FROM 25 | ' . $this->table . ' 26 | ORDER BY 27 | created_at DESC'; 28 | 29 | // Prepare statement 30 | $stmt = $this->conn->prepare($query); 31 | 32 | // Execute query 33 | $stmt->execute(); 34 | 35 | return $stmt; 36 | } 37 | 38 | // Get Single Category 39 | public function read_single(){ 40 | // Create query 41 | $query = 'SELECT 42 | id, 43 | name 44 | FROM 45 | ' . $this->table . ' 46 | WHERE id = ? 47 | LIMIT 0,1'; 48 | 49 | //Prepare statement 50 | $stmt = $this->conn->prepare($query); 51 | 52 | // Bind ID 53 | $stmt->bindParam(1, $this->id); 54 | 55 | // Execute query 56 | $stmt->execute(); 57 | 58 | $row = $stmt->fetch(PDO::FETCH_ASSOC); 59 | 60 | // set properties 61 | $this->id = $row['id']; 62 | $this->name = $row['name']; 63 | } 64 | 65 | // Create Category 66 | public function create() { 67 | // Create Query 68 | $query = 'INSERT INTO ' . 69 | $this->table . ' 70 | SET 71 | name = :name'; 72 | 73 | // Prepare Statement 74 | $stmt = $this->conn->prepare($query); 75 | 76 | // Clean data 77 | $this->name = htmlspecialchars(strip_tags($this->name)); 78 | 79 | // Bind data 80 | $stmt-> bindParam(':name', $this->name); 81 | 82 | // Execute query 83 | if($stmt->execute()) { 84 | return true; 85 | } 86 | 87 | // Print error if something goes wrong 88 | printf("Error: $s.\n", $stmt->error); 89 | 90 | return false; 91 | } 92 | 93 | // Update Category 94 | public function update() { 95 | // Create Query 96 | $query = 'UPDATE ' . 97 | $this->table . ' 98 | SET 99 | name = :name 100 | WHERE 101 | id = :id'; 102 | 103 | // Prepare Statement 104 | $stmt = $this->conn->prepare($query); 105 | 106 | // Clean data 107 | $this->name = htmlspecialchars(strip_tags($this->name)); 108 | $this->id = htmlspecialchars(strip_tags($this->id)); 109 | 110 | // Bind data 111 | $stmt-> bindParam(':name', $this->name); 112 | $stmt-> bindParam(':id', $this->id); 113 | 114 | // Execute query 115 | if($stmt->execute()) { 116 | return true; 117 | } 118 | 119 | // Print error if something goes wrong 120 | printf("Error: $s.\n", $stmt->error); 121 | 122 | return false; 123 | } 124 | 125 | // Delete Category 126 | public function delete() { 127 | // Create query 128 | $query = 'DELETE FROM ' . $this->table . ' WHERE id = :id'; 129 | 130 | // Prepare Statement 131 | $stmt = $this->conn->prepare($query); 132 | 133 | // clean data 134 | $this->id = htmlspecialchars(strip_tags($this->id)); 135 | 136 | // Bind Data 137 | $stmt-> bindParam(':id', $this->id); 138 | 139 | // Execute query 140 | if($stmt->execute()) { 141 | return true; 142 | } 143 | 144 | // Print error if something goes wrong 145 | printf("Error: $s.\n", $stmt->error); 146 | 147 | return false; 148 | } 149 | } 150 | -------------------------------------------------------------------------------- /models/Post.php: -------------------------------------------------------------------------------- 1 | conn = $db; 19 | } 20 | 21 | // Get Posts 22 | public function read() { 23 | // Create query 24 | $query = 'SELECT c.name as category_name, p.id, p.category_id, p.title, p.body, p.author, p.created_at 25 | FROM ' . $this->table . ' p 26 | LEFT JOIN 27 | categories c ON p.category_id = c.id 28 | ORDER BY 29 | p.created_at DESC'; 30 | 31 | // Prepare statement 32 | $stmt = $this->conn->prepare($query); 33 | 34 | // Execute query 35 | $stmt->execute(); 36 | 37 | return $stmt; 38 | } 39 | 40 | // Get Single Post 41 | public function read_single() { 42 | // Create query 43 | $query = 'SELECT c.name as category_name, p.id, p.category_id, p.title, p.body, p.author, p.created_at 44 | FROM ' . $this->table . ' p 45 | LEFT JOIN 46 | categories c ON p.category_id = c.id 47 | WHERE 48 | p.id = ? 49 | LIMIT 0,1'; 50 | 51 | // Prepare statement 52 | $stmt = $this->conn->prepare($query); 53 | 54 | // Bind ID 55 | $stmt->bindParam(1, $this->id); 56 | 57 | // Execute query 58 | $stmt->execute(); 59 | 60 | $row = $stmt->fetch(PDO::FETCH_ASSOC); 61 | 62 | // Set properties 63 | $this->title = $row['title']; 64 | $this->body = $row['body']; 65 | $this->author = $row['author']; 66 | $this->category_id = $row['category_id']; 67 | $this->category_name = $row['category_name']; 68 | } 69 | 70 | // Create Post 71 | public function create() { 72 | // Create query 73 | $query = 'INSERT INTO ' . $this->table . ' SET title = :title, body = :body, author = :author, category_id = :category_id'; 74 | 75 | // Prepare statement 76 | $stmt = $this->conn->prepare($query); 77 | 78 | // Clean data 79 | $this->title = htmlspecialchars(strip_tags($this->title)); 80 | $this->body = htmlspecialchars(strip_tags($this->body)); 81 | $this->author = htmlspecialchars(strip_tags($this->author)); 82 | $this->category_id = htmlspecialchars(strip_tags($this->category_id)); 83 | 84 | // Bind data 85 | $stmt->bindParam(':title', $this->title); 86 | $stmt->bindParam(':body', $this->body); 87 | $stmt->bindParam(':author', $this->author); 88 | $stmt->bindParam(':category_id', $this->category_id); 89 | 90 | // Execute query 91 | if($stmt->execute()) { 92 | return true; 93 | } 94 | 95 | // Print error if something goes wrong 96 | printf("Error: %s.\n", $stmt->error); 97 | 98 | return false; 99 | } 100 | 101 | // Update Post 102 | public function update() { 103 | // Create query 104 | $query = 'UPDATE ' . $this->table . ' 105 | SET title = :title, body = :body, author = :author, category_id = :category_id 106 | WHERE id = :id'; 107 | 108 | // Prepare statement 109 | $stmt = $this->conn->prepare($query); 110 | 111 | // Clean data 112 | $this->title = htmlspecialchars(strip_tags($this->title)); 113 | $this->body = htmlspecialchars(strip_tags($this->body)); 114 | $this->author = htmlspecialchars(strip_tags($this->author)); 115 | $this->category_id = htmlspecialchars(strip_tags($this->category_id)); 116 | $this->id = htmlspecialchars(strip_tags($this->id)); 117 | 118 | // Bind data 119 | $stmt->bindParam(':title', $this->title); 120 | $stmt->bindParam(':body', $this->body); 121 | $stmt->bindParam(':author', $this->author); 122 | $stmt->bindParam(':category_id', $this->category_id); 123 | $stmt->bindParam(':id', $this->id); 124 | 125 | // Execute query 126 | if($stmt->execute()) { 127 | return true; 128 | } 129 | 130 | // Print error if something goes wrong 131 | printf("Error: %s.\n", $stmt->error); 132 | 133 | return false; 134 | } 135 | 136 | // Delete Post 137 | public function delete() { 138 | // Create query 139 | $query = 'DELETE FROM ' . $this->table . ' WHERE id = :id'; 140 | 141 | // Prepare statement 142 | $stmt = $this->conn->prepare($query); 143 | 144 | // Clean data 145 | $this->id = htmlspecialchars(strip_tags($this->id)); 146 | 147 | // Bind data 148 | $stmt->bindParam(':id', $this->id); 149 | 150 | // Execute query 151 | if($stmt->execute()) { 152 | return true; 153 | } 154 | 155 | // Print error if something goes wrong 156 | printf("Error: %s.\n", $stmt->error); 157 | 158 | return false; 159 | } 160 | 161 | } -------------------------------------------------------------------------------- /myblog.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE `categories` ( 2 | `id` int(11) NOT NULL AUTO_INCREMENT, 3 | `name` varchar(255) NOT NULL, 4 | `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, 5 | PRIMARY KEY (`id`) 6 | ); 7 | 8 | INSERT INTO `categories` (`id`, `name`) VALUES 9 | (1, 'Technology'), 10 | (2, 'Gaming'), 11 | (3, 'Auto'), 12 | (4, 'Entertainment'), 13 | (5, 'Books'); 14 | 15 | CREATE TABLE `posts` ( 16 | `id` int(11) NOT NULL AUTO_INCREMENT, 17 | `category_id` int(11) NOT NULL, 18 | `title` varchar(255) NOT NULL, 19 | `body` text NOT NULL, 20 | `author` varchar(255) NOT NULL, 21 | `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, 22 | PRIMARY KEY (`id`) 23 | ); 24 | 25 | INSERT INTO `posts` (`id`, `category_id`, `title`, `body`, `author`) VALUES 26 | (1, 1, 'Technology Post One', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut interdum est nec lorem mattis interdum. Cras augue est, interdum eu consectetur et, faucibus vel turpis. Etiam pulvinar, enim quis elementum iaculis, tortor sapien eleifend eros, vitae rutrum augue quam sed leo. Vivamus fringilla, diam sit amet vestibulum vulputate, urna risus hendrerit arcu, vitae fringilla odio justo vulputate neque. Nulla a massa sed est vehicula rhoncus sit amet quis libero. Integer euismod est quis turpis hendrerit, in feugiat mauris laoreet. Vivamus nec laoreet neque. Cras condimentum aliquam nunc nec maximus. Cras facilisis eros quis leo euismod pharetra sed cursus orci.','Sam Smith'), 27 | (2, 2, 'Gaming Post One', 'Adipiscing elit. Ut interdum est nec lorem mattis interdum. Cras augue est, interdum eu consectetur et, faucibus vel turpis. Etiam pulvinar, enim quis elementum iaculis, tortor sapien eleifend eros, vitae rutrum augue quam sed leo. Vivamus fringilla, diam sit amet vestibulum vulputate, urna risus hendrerit arcu, vitae fringilla odio justo vulputate neque. Nulla a massa sed est vehicula rhoncus sit amet quis libero. Integer euismod est quis turpis hendrerit, in feugiat mauris laoreet. Vivamus nec laoreet neque.','Kevin Williams'), 28 | (3, 1, 'Technology Post Two', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut interdum est nec lorem mattis interdum. Cras augue est, interdum eu consectetur et, faucibus vel turpis. Etiam pulvinar, enim quis elementum iaculis, tortor sapien eleifend eros, vitae rutrum augue quam sed leo. Vivamus fringilla, diam sit amet vestibulum vulputate, urna risus hendrerit arcu, vitae fringilla odio justo vulputate neque. Nulla a massa sed est vehicula rhoncus sit amet quis libero. Integer euismod est quis turpis hendrerit, in feugiat mauris laoreet. Vivamus nec laoreet neque. Cras condimentum aliquam nunc nec maximus. Cras facilisis eros quis leo euismod pharetra sed cursus orci.','Sam Smith'), 29 | (4, 4, 'Entertainment Post One', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut interdum est nec lorem mattis interdum. Cras augue est, interdum eu consectetur et, faucibus vel turpis. Etiam pulvinar, enim quis elementum iaculis, tortor sapien eleifend eros, vitae rutrum augue quam sed leo. Vivamus fringilla, diam sit amet vestibulum vulputate, urna risus hendrerit arcu, vitae fringilla odio justo vulputate neque. Nulla a massa sed est vehicula rhoncus sit amet quis libero. Integer euismod est quis turpis hendrerit, in feugiat mauris laoreet. Vivamus nec laoreet neque. Cras condimentum aliquam nunc nec maximus. Cras facilisis eros quis leo euismod pharetra sed cursus orci.','Mary Jackson'), 30 | (5, 4, 'Entertainment Post Two', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut interdum est nec lorem mattis interdum. Cras augue est, interdum eu consectetur et, faucibus vel turpis. Etiam pulvinar, enim quis elementum iaculis, tortor sapien eleifend eros, vitae rutrum augue quam sed leo. Vivamus fringilla, diam sit amet vestibulum vulputate, urna risus hendrerit arcu, vitae fringilla odio justo vulputate neque. Nulla a massa sed est vehicula rhoncus sit amet quis libero. Integer euismod est quis turpis hendrerit, in feugiat mauris laoreet. Vivamus nec laoreet neque. Cras condimentum aliquam nunc nec maximus. Cras facilisis eros quis leo euismod pharetra sed cursus orci.','Mary Jackson'), 31 | (6, 1, 'Technology Post Three', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut interdum est nec lorem mattis interdum. Cras augue est, interdum eu consectetur et, faucibus vel turpis. Etiam pulvinar, enim quis elementum iaculis, tortor sapien eleifend eros, vitae rutrum augue quam sed leo. Vivamus fringilla, diam sit amet vestibulum vulputate, urna risus hendrerit arcu, vitae fringilla odio justo vulputate neque. Nulla a massa sed est vehicula rhoncus sit amet quis libero. Integer euismod est quis turpis hendrerit, in feugiat mauris laoreet. Vivamus nec laoreet neque. Cras condimentum aliquam nunc nec maximus. Cras facilisis eros quis leo euismod pharetra sed cursus orci.','Sam Smith'); --------------------------------------------------------------------------------