westdc-zf1/application/default/controllers/ObserveController.php

56 lines
1.7 KiB
PHP

<?php
use Helpers\View as view;
class ObserveController extends Zend_Controller_Action
{
private $limit=10;
function __construct(Zend_Controller_Request_Abstract $request, Zend_Controller_Response_Abstract $response, array $invokeArgs = array())
{
parent::__construct($request, $response, $invokeArgs);
$this->_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);
}
}