public function save(Post $post) { $query = "INSERT INTO posts (title, author, content, date, paydoc) VALUES (:title, :author, :content, :date, :paydoc)"; $query_params = array(':title' => $post->getTitle(), ':author' => $post->getAuthor(), ':content' => $post->getContent(), ':date' => $post->getDate(), ':paydoc' => $post->getPayDoc()); try { $stmt = $this->db->prepare($query); $stmt->execute($query_params); return $this->db->lastInsertId(); } catch (PDOException $ex) { die("Failed to run query: " . $ex->getMessage()); } }