实现在线和离线数据的整体查询

This commit is contained in:
wlx 2011-09-14 08:23:26 +00:00
parent 4e11f60ded
commit 12ae3b67e7
1 changed files with 7 additions and 6 deletions

View File

@ -338,9 +338,9 @@ class Admin_DownController extends Zend_Controller_Action
if(empty($show)) if(empty($show))
{ {
$select=$this->db->select(); $select=$this->db->select();
$select->from('onlineapp as o','count(o.id) as num') $select->from('dataorder as o','count(o.id) as num')
->join('metadata as m', 'o.uuid = m.uuid', array('title','uuid')) ->join('metadata as m', 'o.uuid = m.uuid', array('title','uuid'))
->where('o.uuid = m.uuid') ->where('o.uuid = m.uuid and (o.status=0 or o.status=5)')
->group('m.title') ->group('m.title')
->group('m.uuid') ->group('m.uuid')
->order('num desc'); ->order('num desc');
@ -355,18 +355,19 @@ class Admin_DownController extends Zend_Controller_Action
elseif($show) elseif($show)
{ {
$select=$this->db->select(); $select=$this->db->select();
$select->from('onlineapp as o',array('id','username','ts_created','userid')) $select->from('dataorder as o',array('ts_created'))
->join('metadata as m', 'o.uuid = m.uuid', array('title','uuid')) ->join('metadata as m', 'o.uuid = m.uuid', array('title','uuid'))
->where('m.uuid = ?', $show) ->join('users as u', 'o.userid=u.id',array('id as userid','username','realname'))
->where('m.uuid = ? and (o.status=0 or o.status=5)', $show)
->order('o.id desc'); ->order('o.id desc');
$paginator = Zend_Paginator::factory($select); $paginator = Zend_Paginator::factory($select);
$paginator->setCurrentPageNumber($this->_getParam('page')); $paginator->setCurrentPageNumber($this->_getParam('page'));
$paginator->setItemCountPerPage(30); $paginator->setItemCountPerPage($this->view->config->page->max);
$paginator->setView($this->view); $paginator->setView($this->view);
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination.phtml'); Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination.phtml');
$this->view->paginator=$paginator; $this->view->paginator=$paginator;
$sql="select title from metadata where uuid='$show'"; $sql="select title,uuid from metadata where uuid='$show'";
$re=$this->db->query($sql); $re=$this->db->query($sql);
$t=$re->fetch(); $t=$re->fetch();
$this->view->infos=$t; $this->view->infos=$t;