示例#1
0
 public function save(Post $post)
 {
     $title = $post->getTitle();
     $author = $post->getAuthor();
     $content = $post->getContent();
     $date = $post->getDate();
     $payed = $post->isPayedPost();
     $answered = $post->isAnswered();
     // Can't update posts
     if ($post->getPostId() !== null) {
         return;
     }
     $stmt = $this->pdo->prepare("INSERT INTO posts (title, author, content, date, ispayedpost, isanswered) VALUES (?, ?, ?, ?, ?, ?)");
     $stmt->execute(array($title, $author, $content, $date, $payed, $answered));
     return $this->pdo->lastInsertId();
 }