From a7b236531735cdd924c38d875ad9743eb75cb5cb Mon Sep 17 00:00:00 2001 From: wlx Date: Mon, 21 Mar 2016 20:58:29 +0800 Subject: [PATCH] add hot and latest action in search --- .../default/controllers/SearchController.php | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/application/default/controllers/SearchController.php b/application/default/controllers/SearchController.php index 353d57c9..37f172af 100644 --- a/application/default/controllers/SearchController.php +++ b/application/default/controllers/SearchController.php @@ -40,6 +40,33 @@ class SearchController extends Zend_Controller_Action header("Content-Type: application/json; charset=utf-8"); echo $search->suggest($q); } + + function hotAction() + { + $sql="select m.uuid,title from normalmetadata m left join mdstat s on m.uuid=s.uuid order by s.viewed desc limit 10"; + $sth = $this->db->prepare($sql); + $sth ->execute(); + $rows = $sth->fetchAll(); + + $this->_helper->layout->disableLayout(); + $this->_helper->viewRenderer->setNoRender(); + header("Content-Type: application/json; charset=utf-8"); + echo json_encode($rows);; + } + + function latestAction() + { + $sql="select uuid,title from normalmetadata order by ts_created desc limit 10"; + $sth = $this->db->prepare($sql); + $sth ->execute(); + $rows = $sth->fetchAll(); + + $this->_helper->layout->disableLayout(); + $this->_helper->viewRenderer->setNoRender(); + header("Content-Type: application/json; charset=utf-8"); + echo json_encode($rows);; + } + function advanceAction() { $this->view->east=$this->getParam('east');