[
  {
    "path": ".gitignore",
    "content": "jtest.js"
  },
  {
    "path": "README.md",
    "content": "# PHP REST API\n\n> This is a simple PHP REST API from scratch with no framework.\n\n## Quick Start\n\nImport the myblog.sql file, change the params in the config/Database.php file to your own\n\n## App Info\n\n### Author\n\nBrad Traversy\n[Traversy Media](http://www.traversymedia.com)\n\n### Version\n\n1.0.0\n\n### License\n\nThis project is licensed under the MIT License\n"
  },
  {
    "path": "ajaxCall.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta charset=\"UTF-8\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n    <meta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\">\n    <title>Document</title>\n    <script src=\"//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js\" type=\"text/javascript\"></script>\n    <script src=\"ajaxCall.js\"></script>\n\n      <style>\n        body {\n          text-align: center;\n          font-family: \"Helvetica\", sans-serif;\n        }\n        h1 {\n          font-size: 2em;\n          font-weight: bold;\n        }\n        .box {\n          border-radius: 5px;\n          background-color: #eee;\n          padding: 20px 5px;\n        }\n        button {\n          color: white;\n          background-color: #4791d0;\n          border-radius: 5px;\n          border: 1px solid #4791d0;\n          padding: 5px 10px 8px 10px;\n        }\n        button:hover {\n          background-color: #0F5897;\n          border: 1px solid #0F5897;\n        }\n      </style>\n</head>\n<body>\n\n<div style=\"float:left; width:50%;\">\n  <h1>Data Finder</h1> \n  <p class=\"message box\"> The message will go here </p>\n  <p><button id=\"getMessage\"> Get Message </button></p>\n</div> \n\n\n<div style=\"float:right; width:50%;\">\n<h1>Data Sender</h1> \n  <form id=\"apiform\">\n\n    <input type=\"text\" name=\"title\" placeholder=\"title\" autocomplete=\"on\" ><br>\n    <textarea name=\"body\" id=\"\" cols=\"30\" rows=\"10\" placeholder=\"body\" autocomplete=\"on\" ></textarea><br>\n    <input type=\"text\" name=\"author\" placeholder=\"author\" autocomplete=\"on\" ><br>\n    <input type=\"text\" name=\"category_id\" placeholder=\"category_id\" autocomplete=\"on\" ><br><br>\n\n    <button id=\"postMessage\"> Post Message </button>\n  </form>\n</div>\n\n\n</body>\n</html>\n\n\n\n\n\n\n"
  },
  {
    "path": "ajaxCall.js",
    "content": "\n//POST REQUEST\n\n$(document).ready(function(){\n    $('#postMessage').click(function(e){\n        e.preventDefault();\n\n        //serialize form data\n        var url = $('form').serialize();\n\n        //function to turn url to an object\n        function getUrlVars(url) {\n            var hash;\n            var myJson = {};\n            var hashes = url.slice(url.indexOf('?') + 1).split('&');\n            for (var i = 0; i < hashes.length; i++) {\n                hash = hashes[i].split('=');\n                myJson[hash[0]] = hash[1];\n            }\n            return JSON.stringify(myJson);\n        }\n\n        //pass serialized data to function\n        var test = getUrlVars(url);\n\n        //post with ajax\n        $.ajax({\n            type:\"POST\",\n            url: \"/Work folders/OOP php/RESTFUL traversy/php_rest_myblog/api/post/create.php\",\n            data: test,\n            ContentType:\"application/json\",\n\n            success:function(){\n                alert('successfully posted');\n            },\n            error:function(){\n                alert('Could not be posted');\n            }\n\n        });\n    });\n});\n    \n\n//GET REQUEST\n\n  document.addEventListener('DOMContentLoaded',function(){\n  document.getElementById('getMessage').onclick=function(){\n       \n       var req;\n       req=new XMLHttpRequest();\n       req.open(\"GET\", '/Work folders/OOP php/RESTFUL traversy/php_rest_myblog/api/post/read.php',true);\n       req.send();\n      \n       req.onload=function(){\n       var json=JSON.parse(req.responseText);\n\n       //limit data called\n       var son = json.filter(function(val) {\n              return (val.id >= 4);  \n          });\n\n      var html = \"\";\n\n      //loop and display data\n      son.forEach(function(val) {\n          var keys = Object.keys(val);\n\n          html += \"<div class = 'cat'>\";\n              keys.forEach(function(key) {\n              html += \"<strong>\" + key + \"</strong>: \" + val[key] + \"<br>\";\n              });\n          html += \"</div><br>\";\n      });\n\n      //append in message class\n      document.getElementsByClassName('message')[0].innerHTML=html;         \n      };\n    };\n  });\n  \n"
  },
  {
    "path": "api/category/create.php",
    "content": "<?php\n  // Headers\n  header('Access-Control-Allow-Origin: *');\n  header('Content-Type: application/json');\n  header('Access-Control-Allow-Methods: POST');\n  header('Access-Control-Allow-Headers: Access-Control-Allow-Headers, Content-Type, Access-Control-Allow-Methods, Authorization,X-Requested-With');\n\n  include_once '../../config/Database.php';\n  include_once '../../models/Category.php';\n  // Instantiate DB & connect\n  $database = new Database();\n  $db = $database->connect();\n\n  // Instantiate blog post object\n  $category = new Category($db);\n\n  // Get raw posted data\n  $data = json_decode(file_get_contents(\"php://input\"));\n\n  $category->name = $data->name;\n\n  // Create Category\n  if($category->create()) {\n    echo json_encode(\n      array('message' => 'Category Created')\n    );\n  } else {\n    echo json_encode(\n      array('message' => 'Category Not Created')\n    );\n  }\n"
  },
  {
    "path": "api/category/delete.php",
    "content": "<?php\n  // Headers\n  header('Access-Control-Allow-Origin: *');\n  header('Content-Type: application/json');\n  header('Access-Control-Allow-Methods: DELETE');\n  header('Access-Control-Allow-Headers: Access-Control-Allow-Headers, Content-Type, Access-Control-Allow-Methods, Authorization,X-Requested-With');\n\n  include_once '../../config/Database.php';\n  include_once '../../models/Category.php';\n  // Instantiate DB & connect\n  $database = new Database();\n  $db = $database->connect();\n\n  // Instantiate blog post object\n  $category = new Category($db);\n\n  // Get raw posted data\n  $data = json_decode(file_get_contents(\"php://input\"));\n\n  // Set ID to UPDATE\n  $category->id = $data->id;\n\n  // Delete post\n  if($category->delete()) {\n    echo json_encode(\n      array('message' => 'Category deleted')\n    );\n  } else {\n    echo json_encode(\n      array('message' => 'Category not deleted')\n    );\n  }\n"
  },
  {
    "path": "api/category/read.php",
    "content": "<?php \n  // Headers\n  header('Access-Control-Allow-Origin: *');\n  header('Content-Type: application/json');\n\n  include_once '../../config/Database.php';\n  include_once '../../models/Category.php';\n\n  // Instantiate DB & connect\n  $database = new Database();\n  $db = $database->connect();\n\n  // Instantiate category object\n  $category = new Category($db);\n\n  // Category read query\n  $result = $category->read();\n  \n  // Get row count\n  $num = $result->rowCount();\n\n  // Check if any categories\n  if($num > 0) {\n        // Cat array\n        $cat_arr = array();\n        $cat_arr['data'] = array();\n\n        while($row = $result->fetch(PDO::FETCH_ASSOC)) {\n          extract($row);\n\n          $cat_item = array(\n            'id' => $id,\n            'name' => $name\n          );\n\n          // Push to \"data\"\n          array_push($cat_arr['data'], $cat_item);\n        }\n\n        // Turn to JSON & output\n        echo json_encode($cat_arr);\n\n  } else {\n        // No Categories\n        echo json_encode(\n          array('message' => 'No Categories Found')\n        );\n  }\n"
  },
  {
    "path": "api/category/read_single.php",
    "content": "<?php\n\n  // Headers\n  header('Access-Control-Allow-Origin: *');\n  header('Content-Type: application/json');\n\n  include_once '../../config/Database.php';\n  include_once '../../models/Category.php';\n  // Instantiate DB & connect\n  $database = new Database();\n  $db = $database->connect();\n  // Instantiate blog category object\n  $category = new Category($db);\n\n  // Get ID\n  $category->id = isset($_GET['id']) ? $_GET['id'] : die();\n\n  // Get post\n  $category->read_single();\n\n  // Create array\n  $category_arr = array(\n    'id' => $category->id,\n    'name' => $category->name\n  );\n\n  // Make JSON\n  print_r(json_encode($category_arr));\n"
  },
  {
    "path": "api/category/update.php",
    "content": "<?php\n  // Headers\n  header('Access-Control-Allow-Origin: *');\n  header('Content-Type: application/json');\n  header('Access-Control-Allow-Methods: PUT');\n  header('Access-Control-Allow-Headers: Access-Control-Allow-Headers, Content-Type, Access-Control-Allow-Methods, Authorization,X-Requested-With');\n\n  include_once '../../config/Database.php';\n  include_once '../../models/Category.php';\n  // Instantiate DB & connect\n  $database = new Database();\n  $db = $database->connect();\n\n  // Instantiate blog post object\n  $category = new Category($db);\n\n  // Get raw posted data\n  $data = json_decode(file_get_contents(\"php://input\"));\n\n  // Set ID to UPDATE\n  $category->id = $data->id;\n\n  $category->name = $data->name;\n\n  // Update post\n  if($category->update()) {\n    echo json_encode(\n      array('message' => 'Category Updated')\n    );\n  } else {\n    echo json_encode(\n      array('message' => 'Category not updated')\n    );\n  }\n"
  },
  {
    "path": "api/post/create.php",
    "content": "<?php \n  // Headers\n  header('Access-Control-Allow-Origin: *');\n  header('Content-Type: application/json');\n  header('Access-Control-Allow-Methods: POST');\n  header('Access-Control-Allow-Headers: Access-Control-Allow-Headers,Content-Type,Access-Control-Allow-Methods, Authorization, X-Requested-With');\n\n  include_once '../../config/Database.php';\n  include_once '../../models/Post.php';\n\n  // Instantiate DB & connect\n  $database = new Database();\n  $db = $database->connect();\n\n  // Instantiate blog post object\n  $post = new Post($db);\n\n  // Get raw posted data\n  $data = json_decode(file_get_contents(\"php://input\"));\n\n  $post->title = $data->title;\n  $post->body = $data->body;\n  $post->author = $data->author;\n  $post->category_id = $data->category_id;\n\n  // Create post\n  if($post->create()) {\n    echo json_encode(\n      array('message' => 'Post Created')\n    );\n  } else {\n    echo json_encode(\n      array('message' => 'Post Not Created')\n    );\n  }\n\n"
  },
  {
    "path": "api/post/delete.php",
    "content": "<?php \n  // Headers\n  header('Access-Control-Allow-Origin: *');\n  header('Content-Type: application/json');\n  header('Access-Control-Allow-Methods: DELETE');\n  header('Access-Control-Allow-Headers: Access-Control-Allow-Headers,Content-Type,Access-Control-Allow-Methods, Authorization, X-Requested-With');\n\n  include_once '../../config/Database.php';\n  include_once '../../models/Post.php';\n\n  // Instantiate DB & connect\n  $database = new Database();\n  $db = $database->connect();\n\n  // Instantiate blog post object\n  $post = new Post($db);\n\n  // Get raw posted data\n  $data = json_decode(file_get_contents(\"php://input\"));\n\n  // Set ID to update\n  $post->id = $data->id;\n\n  // Delete post\n  if($post->delete()) {\n    echo json_encode(\n      array('message' => 'Post Deleted')\n    );\n  } else {\n    echo json_encode(\n      array('message' => 'Post Not Deleted')\n    );\n  }\n\n"
  },
  {
    "path": "api/post/read.php",
    "content": "<?php \n  // Headers\n  header('Access-Control-Allow-Origin: *');\n  header('Content-Type: application/json');\n\n  include_once '../../config/Database.php';\n  include_once '../../models/Post.php';\n\n  // Instantiate DB & connect\n  $database = new Database();\n  $db = $database->connect();\n\n  // Instantiate blog post object\n  $post = new Post($db);\n\n  // Blog post query\n  $result = $post->read();\n  // Get row count\n  $num = $result->rowCount();\n\n  // Check if any posts\n  if($num > 0) {\n    // Post array\n    $posts_arr = array();\n    // $posts_arr['data'] = array();\n\n    while($row = $result->fetch(PDO::FETCH_ASSOC)) {\n      extract($row);\n\n      $post_item = array(\n        'id' => $id,\n        'title' => $title,\n        'body' => html_entity_decode($body),\n        'author' => $author,\n        'category_id' => $category_id,\n        'category_name' => $category_name\n      );\n\n      // Push to \"data\"\n      array_push($posts_arr, $post_item);\n      // array_push($posts_arr['data'], $post_item);\n    }\n\n    // Turn to JSON & output\n    echo json_encode($posts_arr);\n\n  } else {\n    // No Posts\n    echo json_encode(\n      array('message' => 'No Posts Found')\n    );\n  }\n"
  },
  {
    "path": "api/post/read_single.php",
    "content": "<?php \n  // Headers\n  header('Access-Control-Allow-Origin: *');\n  header('Content-Type: application/json');\n\n  include_once '../../config/Database.php';\n  include_once '../../models/Post.php';\n\n  // Instantiate DB & connect\n  $database = new Database();\n  $db = $database->connect();\n\n  // Instantiate blog post object\n  $post = new Post($db);\n\n  // Get ID\n  $post->id = isset($_GET['id']) ? $_GET['id'] : die();\n\n  // Get post\n  $post->read_single();\n\n  // Create array\n  $post_arr = array(\n    'id' => $post->id,\n    'title' => $post->title,\n    'body' => $post->body,\n    'author' => $post->author,\n    'category_id' => $post->category_id,\n    'category_name' => $post->category_name\n  );\n\n  // Make JSON\n  print_r(json_encode($post_arr));"
  },
  {
    "path": "api/post/update.php",
    "content": "<?php \n  // Headers\n  header('Access-Control-Allow-Origin: *');\n  header('Content-Type: application/json');\n  header('Access-Control-Allow-Methods: PUT');\n  header('Access-Control-Allow-Headers: Access-Control-Allow-Headers,Content-Type,Access-Control-Allow-Methods, Authorization, X-Requested-With');\n\n  include_once '../../config/Database.php';\n  include_once '../../models/Post.php';\n\n  // Instantiate DB & connect\n  $database = new Database();\n  $db = $database->connect();\n\n  // Instantiate blog post object\n  $post = new Post($db);\n\n  // Get raw posted data\n  $data = json_decode(file_get_contents(\"php://input\"));\n\n  // Set ID to update\n  $post->id = $data->id;\n\n  $post->title = $data->title;\n  $post->body = $data->body;\n  $post->author = $data->author;\n  $post->category_id = $data->category_id;\n\n  // Update post\n  if($post->update()) {\n    echo json_encode(\n      array('message' => 'Post Updated')\n    );\n  } else {\n    echo json_encode(\n      array('message' => 'Post Not Updated')\n    );\n  }\n\n"
  },
  {
    "path": "config/Database.php",
    "content": "<?php \n  class Database {\n    // DB Params\n    private $host = 'localhost';\n    private $db_name = 'myblog';\n    private $username = 'root';\n    private $password = '';\n    private $conn;\n\n    // DB Connect\n    public function connect() {\n      $this->conn = null;\n\n      try { \n        $this->conn = new PDO('mysql:host=' . $this->host . ';dbname=' . $this->db_name, $this->username, $this->password);\n        $this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);\n      } catch(PDOException $e) {\n        echo 'Connection Error: ' . $e->getMessage();\n      }\n\n      return $this->conn;\n    }\n  }"
  },
  {
    "path": "models/Category.php",
    "content": "<?php\n  class Category {\n    // DB Stuff\n    private $conn;\n    private $table = 'categories';\n\n    // Properties\n    public $id;\n    public $name;\n    public $created_at;\n\n    // Constructor with DB\n    public function __construct($db) {\n      $this->conn = $db;\n    }\n\n    // Get categories\n    public function read() {\n      // Create query\n      $query = 'SELECT\n        id,\n        name,\n        created_at\n      FROM\n        ' . $this->table . '\n      ORDER BY\n        created_at DESC';\n\n      // Prepare statement\n      $stmt = $this->conn->prepare($query);\n\n      // Execute query\n      $stmt->execute();\n\n      return $stmt;\n    }\n\n    // Get Single Category\n  public function read_single(){\n    // Create query\n    $query = 'SELECT\n          id,\n          name\n        FROM\n          ' . $this->table . '\n      WHERE id = ?\n      LIMIT 0,1';\n\n      //Prepare statement\n      $stmt = $this->conn->prepare($query);\n\n      // Bind ID\n      $stmt->bindParam(1, $this->id);\n\n      // Execute query\n      $stmt->execute();\n\n      $row = $stmt->fetch(PDO::FETCH_ASSOC);\n\n      // set properties\n      $this->id = $row['id'];\n      $this->name = $row['name'];\n  }\n\n  // Create Category\n  public function create() {\n    // Create Query\n    $query = 'INSERT INTO ' .\n      $this->table . '\n    SET\n      name = :name';\n\n  // Prepare Statement\n  $stmt = $this->conn->prepare($query);\n\n  // Clean data\n  $this->name = htmlspecialchars(strip_tags($this->name));\n\n  // Bind data\n  $stmt-> bindParam(':name', $this->name);\n\n  // Execute query\n  if($stmt->execute()) {\n    return true;\n  }\n\n  // Print error if something goes wrong\n  printf(\"Error: $s.\\n\", $stmt->error);\n\n  return false;\n  }\n\n  // Update Category\n  public function update() {\n    // Create Query\n    $query = 'UPDATE ' .\n      $this->table . '\n    SET\n      name = :name\n      WHERE\n      id = :id';\n\n  // Prepare Statement\n  $stmt = $this->conn->prepare($query);\n\n  // Clean data\n  $this->name = htmlspecialchars(strip_tags($this->name));\n  $this->id = htmlspecialchars(strip_tags($this->id));\n\n  // Bind data\n  $stmt-> bindParam(':name', $this->name);\n  $stmt-> bindParam(':id', $this->id);\n\n  // Execute query\n  if($stmt->execute()) {\n    return true;\n  }\n\n  // Print error if something goes wrong\n  printf(\"Error: $s.\\n\", $stmt->error);\n\n  return false;\n  }\n\n  // Delete Category\n  public function delete() {\n    // Create query\n    $query = 'DELETE FROM ' . $this->table . ' WHERE id = :id';\n\n    // Prepare Statement\n    $stmt = $this->conn->prepare($query);\n\n    // clean data\n    $this->id = htmlspecialchars(strip_tags($this->id));\n\n    // Bind Data\n    $stmt-> bindParam(':id', $this->id);\n\n    // Execute query\n    if($stmt->execute()) {\n      return true;\n    }\n\n    // Print error if something goes wrong\n    printf(\"Error: $s.\\n\", $stmt->error);\n\n    return false;\n    }\n  }\n"
  },
  {
    "path": "models/Post.php",
    "content": "<?php \n  class Post {\n    // DB stuff\n    private $conn;\n    private $table = 'posts';\n\n    // Post Properties\n    public $id;\n    public $category_id;\n    public $category_name;\n    public $title;\n    public $body;\n    public $author;\n    public $created_at;\n\n    // Constructor with DB\n    public function __construct($db) {\n      $this->conn = $db;\n    }\n\n    // Get Posts\n    public function read() {\n      // Create query\n      $query = 'SELECT c.name as category_name, p.id, p.category_id, p.title, p.body, p.author, p.created_at\n                                FROM ' . $this->table . ' p\n                                LEFT JOIN\n                                  categories c ON p.category_id = c.id\n                                ORDER BY\n                                  p.created_at DESC';\n      \n      // Prepare statement\n      $stmt = $this->conn->prepare($query);\n\n      // Execute query\n      $stmt->execute();\n\n      return $stmt;\n    }\n\n    // Get Single Post\n    public function read_single() {\n          // Create query\n          $query = 'SELECT c.name as category_name, p.id, p.category_id, p.title, p.body, p.author, p.created_at\n                                    FROM ' . $this->table . ' p\n                                    LEFT JOIN\n                                      categories c ON p.category_id = c.id\n                                    WHERE\n                                      p.id = ?\n                                    LIMIT 0,1';\n\n          // Prepare statement\n          $stmt = $this->conn->prepare($query);\n\n          // Bind ID\n          $stmt->bindParam(1, $this->id);\n\n          // Execute query\n          $stmt->execute();\n\n          $row = $stmt->fetch(PDO::FETCH_ASSOC);\n\n          // Set properties\n          $this->title = $row['title'];\n          $this->body = $row['body'];\n          $this->author = $row['author'];\n          $this->category_id = $row['category_id'];\n          $this->category_name = $row['category_name'];\n    }\n\n    // Create Post\n    public function create() {\n          // Create query\n          $query = 'INSERT INTO ' . $this->table . ' SET title = :title, body = :body, author = :author, category_id = :category_id';\n\n          // Prepare statement\n          $stmt = $this->conn->prepare($query);\n\n          // Clean data\n          $this->title = htmlspecialchars(strip_tags($this->title));\n          $this->body = htmlspecialchars(strip_tags($this->body));\n          $this->author = htmlspecialchars(strip_tags($this->author));\n          $this->category_id = htmlspecialchars(strip_tags($this->category_id));\n\n          // Bind data\n          $stmt->bindParam(':title', $this->title);\n          $stmt->bindParam(':body', $this->body);\n          $stmt->bindParam(':author', $this->author);\n          $stmt->bindParam(':category_id', $this->category_id);\n\n          // Execute query\n          if($stmt->execute()) {\n            return true;\n      }\n\n      // Print error if something goes wrong\n      printf(\"Error: %s.\\n\", $stmt->error);\n\n      return false;\n    }\n\n    // Update Post\n    public function update() {\n          // Create query\n          $query = 'UPDATE ' . $this->table . '\n                                SET title = :title, body = :body, author = :author, category_id = :category_id\n                                WHERE id = :id';\n\n          // Prepare statement\n          $stmt = $this->conn->prepare($query);\n\n          // Clean data\n          $this->title = htmlspecialchars(strip_tags($this->title));\n          $this->body = htmlspecialchars(strip_tags($this->body));\n          $this->author = htmlspecialchars(strip_tags($this->author));\n          $this->category_id = htmlspecialchars(strip_tags($this->category_id));\n          $this->id = htmlspecialchars(strip_tags($this->id));\n\n          // Bind data\n          $stmt->bindParam(':title', $this->title);\n          $stmt->bindParam(':body', $this->body);\n          $stmt->bindParam(':author', $this->author);\n          $stmt->bindParam(':category_id', $this->category_id);\n          $stmt->bindParam(':id', $this->id);\n\n          // Execute query\n          if($stmt->execute()) {\n            return true;\n          }\n\n          // Print error if something goes wrong\n          printf(\"Error: %s.\\n\", $stmt->error);\n\n          return false;\n    }\n\n    // Delete Post\n    public function delete() {\n          // Create query\n          $query = 'DELETE FROM ' . $this->table . ' WHERE id = :id';\n\n          // Prepare statement\n          $stmt = $this->conn->prepare($query);\n\n          // Clean data\n          $this->id = htmlspecialchars(strip_tags($this->id));\n\n          // Bind data\n          $stmt->bindParam(':id', $this->id);\n\n          // Execute query\n          if($stmt->execute()) {\n            return true;\n          }\n\n          // Print error if something goes wrong\n          printf(\"Error: %s.\\n\", $stmt->error);\n\n          return false;\n    }\n    \n  }"
  },
  {
    "path": "myblog.sql",
    "content": "CREATE TABLE `categories` (\n  `id` int(11) NOT NULL AUTO_INCREMENT,\n  `name` varchar(255) NOT NULL,\n  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,\n  PRIMARY KEY (`id`)\n);\n\nINSERT INTO `categories` (`id`, `name`) VALUES\n(1, 'Technology'),\n(2, 'Gaming'),\n(3, 'Auto'),\n(4, 'Entertainment'),\n(5, 'Books');\n\nCREATE TABLE `posts` (\n  `id` int(11) NOT NULL AUTO_INCREMENT,\n  `category_id` int(11) NOT NULL,\n  `title` varchar(255) NOT NULL,\n  `body` text NOT NULL,\n  `author` varchar(255) NOT NULL,\n  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,\n  PRIMARY KEY (`id`)\n);\n\nINSERT INTO `posts` (`id`, `category_id`, `title`, `body`, `author`) VALUES\n(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'),\n(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'),\n(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'),\n(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'),\n(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'),\n(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');"
  }
]