Beispiel #1
0
 /**
  * setNewPost
  * @param string $headline
  * @param string $body
  * @param int $categoryId
  * @param int $online
  * @return int
  */
 public static function setNewPost(Post $post)
 {
     $pdoMysql = new PdoMysql();
     $pdoMysql->conn();
     $sql = "INSERT INTO post_data (`headline`\n                                   , `body`\n                                   , `category_id`\n                                   , `online`\n                                   , `post_date`)\n                           VAlUES (:headline\n                                   , :body\n                                   , :category_id\n                                   , :online\n                                   , {$post->bindings['post_date']->value})";
     unset($post->bindings['post_date']);
     unset($post->bindings['id']);
     $rv = $pdoMysql->query($sql, $post->bindings);
     if (is_a($rv, 'ErrorObject')) {
         $rv->caller = $_SERVER['SCRIPT_FILENAME'];
         return $rv;
     }
     return $pdoMysql->getLastInsertId();
 }
Beispiel #2
0
 public static function setNewReply(Comments $comment, $parentId)
 {
     $commentId = self::setNewComment($comment);
     if (is_a($commentId, 'ErrorObject')) {
         $commentId->caller = $_SERVER['SCRIPT_FILENAME'];
         return $commentId;
     }
     $pdoMysql = new PdoMysql();
     $pdoMysql->conn();
     $sql = "INSERT INTO replies ( comment_id, parent_id)\n                         VALUES ( :commentId, :parentId)";
     $bindValues = array('commentId' => $commentId, 'parentId' => $parentId);
     $rv = $pdoMysql->query($sql, $bindValues);
     if (is_a($rv, 'ErrorObject')) {
         $rv->caller = $_SERVER['SCRIPT_FILENAME'];
         return $rv;
     }
     self::alertComment($comment);
     return $pdoMysql->getLastInsertId();
 }
 public static function setNewCategory($newCategory)
 {
     $pdoMysql = new PdoMysql();
     $pdoMysql->conn();
     $sql = "INSERT INTO categories (`category`) VALUES ( :newCategory )";
     $bindValues = array('newCategory' => $newCategory);
     $rv = $pdoMysql->query($sql, $bindValues);
     if (is_a($rv, 'ErrorObject')) {
         $rv->caller = $_SERVER['SCRIPT_FILENAME'];
         return $rv;
     }
     return $pdoMysql->getLastInsertId();
 }
Beispiel #4
0
 public static function setNewUser(Users $newUser)
 {
     $pdoMysql = new PdoMysql();
     $pdoMysql->conn();
     $sql = "INSERT INTO users (`user_name`\n                               , `user_type`\n                               , `email`\n                               , `user_pw`\n                               , `date_joined`)\n                        VALUES (:user_name\n                               , :user_type\n                               , :email\n                               , :user_pw\n                               , :date_joined)";
     unset($newUser->bindings['id']);
     $rv = $pdoMysql->query($sql, $newUser->bindings);
     if (is_a($rv, 'ErrorObject')) {
         $rv->caller = $_SERVER['SCRIPT_FILENAME'];
         return $rv;
     }
     return $pdoMysql->getLastInsertId();
 }