_helper->layout->setLayout('layout-sanji'); } public function jsonexit($data){ $this->getResponse()->setHeader('Content-Type', 'application/json')->appendBody(json_encode($data,JSON_NUMERIC_CHECK)); return true; } function preDispatch() { $this->db=Zend_Registry::get('db'); $this->view->config = Zend_Registry::get('config'); $this->messenger=$this->_helper->getHelper('FlashMessenger'); $this->view->messages = $this->messenger->getMessages(); $this->view->theme = new Theme(); $this->view->main_nav_pageID = "data"; $this->view->nav = array( array('link'=>'/','title'=>'首页'), array('link'=>'/data','title'=>$this->view->config->title->data), ); } function indexAction() { } function dataAction(){ $this->_helper->viewRenderer->setNoRender(); $this->_helper->layout->disableLayout(); $db = Zend_Db::factory($this->view->config->data); $variable = $this->_getParam('variable'); $sql = "SELECT \"$variable\", \"date\" FROM guoluo_atomsphere WHERE \"$variable\"!='-99999' ORDER BY date ASC"; $stmt = $db->query($sql); $stmt->setFetchMode(Zend_Db::FETCH_NUM); $result = $stmt->fetchAll(); $this->jsonexit($result); } }