示例#1
0
 /**
  * Search for blog posts based on the requested searchTerm
  */
 public function indexAction()
 {
     //save Request variable searchTerm
     $searchTerm = $this->Request()->searchTerm;
     $sql = "SELECT * FROM post WHERE headline like :value OR content like :value";
     $this->View()->posts = Blog()->Db()->fetchAll($sql, array("value" => "%" . $searchTerm . "%"));
     //just to highlight the current menu
     $this->View()->activeMenu = $this->Request()->getControllerName();
 }
示例#2
0
 /**
  * Will be called by default if no other action is called.
  * Reads all blog posts order by creation date
  */
 public function indexAction()
 {
     $sql = "SELECT * FROM post ORDER BY creation_date DESC ";
     $posts = Blog()->Db()->fetchAll($sql);
     //allocates all posts to the view so you can access them via smarty
     $this->View()->posts = $posts;
     //just to highlight the current menu
     $this->View()->activeMenu = $this->Request()->getControllerName();
 }
示例#3
0
 /**
  * Will be called by default if no other action is called.
  * Reads the blog post with the requested postID from the db and
  * reads different three blog posts to teaser them
  */
 public function indexAction()
 {
     //save Request variable postID
     $postId = intval($this->Request()->postID);
     $sql = "SELECT * FROM post WHERE id = ?";
     $post = Blog()->Db()->fetchRow($sql, array($postId));
     //allocates all posts to the view so you can access them via smarty
     $this->View()->post = $post;
     $sql = "SELECT * FROM post WHERE id != ? ORDER by creation_date LIMIT 3 ";
     $posts = Blog()->Db()->fetchAll($sql, array($postId));
     $this->View()->teaserPosts = $posts;
 }
示例#4
0
 /**
  * updates the blog post based on the request data
  * @return JsonData  success message
  */
 public function deletePostAction()
 {
     $postID = $this->Request()->id;
     $sql = "DELETE FROM `post` WHERE `id` = ?";
     Blog()->Db()->query($sql, $postID);
     echo Zend_Json::encode(array('success' => true));
 }