db=Zend_Registry::get('db'); $this->view->config = Zend_Registry::get('config'); $this->messenger=$this->_helper->getHelper('FlashMessenger'); $this->view->messages = $this->messenger->getMessages(); } function postDispatch() { $this->view->messages = $this->messenger->getMessages(); } function indexAction() { $select=$this->db->select(); $select->from('onlineapp as o',array('id','username','ts_created')) //->where('usertype = ?', 'member') ->join('metadata as m', 'o.uuid = m.uuid', array('title','uuid')) ->order('o.id desc'); $paginator = Zend_Paginator::factory($select); $paginator->setCurrentPageNumber($this->_getParam('page')); $paginator->setItemCountPerPage(30); $paginator->setView($this->view); Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination.phtml'); $this->view->paginator=$paginator; $count="select count(id) as total from onlineapp"; $re=$this->db->query($count); $t=$re->fetch(); $this->view->t=$t; }//indexAction function deleteAction() { $delete=(int)$this->_getParam('id'); if (isset($delete)) { $sql="delete from onlineapp where id=?"; try { $this->db->query($sql,array($delete)); $this->messenger->addMessage('该记录已删除'); } catch (Exception $e) { $this->messenger->addMessage($e->getMessage()); } $this->_redirect("/admin/onlineapp/"); } }//deleteAction function showAction() { $id = $this->_request->getParam('id'); if (!empty($id)) { $sql ="select o.*,u.username as uname,u.id as uid,m.title,m.uuid from onlineapp as o left join users as u on u.id = o.userid left join metadata as m on o.uuid = m.uuid where o.id=?"; $result =$this->db->query($sql,$id); $rows = $result->fetch(); $this->view->infos=$rows; } }//showAction function datasAction() { $select=$this->db->select(); $select->from('onlineapp as o','count(o.id) as num') ->join('metadata as m', 'o.uuid = m.uuid', array('title','uuid')) ->where('o.uuid = m.uuid') ->group('m.title') ->group('m.uuid') ->order('num desc'); $paginator = Zend_Paginator::factory($select); $paginator->setCurrentPageNumber($this->_getParam('page')); $paginator->setItemCountPerPage(30); $paginator->setView($this->view); Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination.phtml'); $this->view->paginator=$paginator; /*$sql="select m.title,count(o.id) as num from onlineapp as o left join metadata as m on m.uuid=o.uuid where o.uuid=m.uuid group by m.title";*/ }//datasAction function showdataAction() { $uuid = $this->_request->getParam('uuid'); if(!empty($uuid)) { $select=$this->db->select(); $select->from('onlineapp as o',array('id','username','ts_created')) ->join('metadata as m', 'o.uuid = m.uuid', array('title','uuid')) ->where('m.uuid = ?', $uuid) ->order('o.id desc'); $paginator = Zend_Paginator::factory($select); $paginator->setCurrentPageNumber($this->_getParam('page')); $paginator->setItemCountPerPage(30); $paginator->setView($this->view); Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination.phtml'); $this->view->paginator=$paginator; $sql="select title from metadata where uuid='$uuid'"; $re=$this->db->query($sql); $t=$re->fetch(); $this->view->infos=$t; }else { $this->_redirect("/admin/onlineapp/"); } }//showdataAction function usersAction() { $select=$this->db->select(); $select->from('onlineapp as o','count(o.id) as num') ->join('users as u', 'u.id = o.userid', array('realname','id as uid')) ->where('o.userid = u.id') ->group('uid') ->group('realname') ->order('num desc'); $paginator = Zend_Paginator::factory($select); $paginator->setCurrentPageNumber($this->_getParam('page')); $paginator->setItemCountPerPage(30); $paginator->setView($this->view); Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination.phtml'); $this->view->paginator=$paginator; }//usersAction function showuserAction() { $id = $this->_request->getParam('id'); if(!empty($id)) { $select=$this->db->select(); $select->from('onlineapp as o',array('id','username','ts_created')) ->join('metadata as m', 'o.uuid = m.uuid', array('title','uuid')) ->where('o.userid = ?', $id) ->order('o.id desc'); $paginator = Zend_Paginator::factory($select); $paginator->setCurrentPageNumber($this->_getParam('page')); $paginator->setItemCountPerPage(30); $paginator->setView($this->view); Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination.phtml'); $this->view->paginator=$paginator; $sql="select username,realname from users where id='$id'"; $re=$this->db->query($sql); $t=$re->fetch(); $this->view->infos=$t; }else { $this->_redirect("/admin/onlineapp/"); } }//showuserAction }