perfect the paginator service and zend db service,add new functions in review service

This commit is contained in:
Jianxuan Li 2015-01-14 00:25:56 +08:00
parent 9a7e8c9b1e
commit 32806de819
3 changed files with 41 additions and 7 deletions

View File

@ -30,10 +30,6 @@ class Paginator implements ServiceManagerAwareInterface{
{ {
$this->serviceManager = $serviceManager; $this->serviceManager = $serviceManager;
$this->setPageLimit();
$this->setPageRange();
$this->setRoute();
return $this; return $this;
} }
@ -97,6 +93,16 @@ class Paginator implements ServiceManagerAwareInterface{
{ {
$page = $ctl->params()->fromRoute('page'); $page = $ctl->params()->fromRoute('page');
if(empty($this->pageLimit))
$this->setPageLimit();
if(empty($this->pageRange))
$this->setPageRange();
if(empty($this->route))
$this->setRoute();
if(is_array($data)) if(is_array($data))
$data = new ArrayAdapter($data); $data = new ArrayAdapter($data);

View File

@ -10,6 +10,7 @@ namespace Westdc\Review;
use Zend\ServiceManager\ServiceManager; use Zend\ServiceManager\ServiceManager;
use Zend\ServiceManager\ServiceManagerAwareInterface; use Zend\ServiceManager\ServiceManagerAwareInterface;
use Westdc\EventModel\AbstractEventManager; use Westdc\EventModel\AbstractEventManager;
use Zend\Db\Sql\Select;
class Review extends AbstractEventManager implements ServiceManagerAwareInterface{ class Review extends AbstractEventManager implements ServiceManagerAwareInterface{
@ -124,10 +125,37 @@ class Review extends AbstractEventManager implements ServiceManagerAwareInterfac
{$this->limitSql}"; {$this->limitSql}";
$rs = $this->db->query($sql); $rs = $this->db->query($sql);
return $rs->fetchAll(); return $rs->fetchAll(\PDO::FETCH_ASSOC);
}//getDraft() }//getDraft()
/**
* 获取被取消评审的元数据
* @return mixed
*/
public function getCanceled()
{
$this->processOptions();
$searchJoin = "";
if(isset($this->opt->keyword) && !empty($this->opt->keyword))
{
$searchJoin = " AND md.title LIKE '%{$this->opt->keyword}%'";
}
if(empty($this->orderSql))
{
$this->orderSql = "ORDER BY m.ts_created DESC";
}
$sql = "SELECT m.id,md.title,md.uuid,m.status,m.ts_created FROM mdstatus m
RIGHT JOIN metadata md ON md.uuid=m.uuid
WHERE m.status=".self::REVIEW_STATUS_CANCELED." $searchJoin
{$this->orderSql} {$this->sortSql}
{$this->limitSql}";
$rs = $this->db->query($sql);
return $rs->fetchAll(\PDO::FETCH_ASSOC);
}
/** /**
* 取消评审 * 取消评审

View File

@ -14,7 +14,7 @@ class Db {
public function getZendDb(){ public function getZendDb(){
$dbObject = new WestdcDb\Db($adapter); $dbObject = new WestdcDb\Db();
return $dbObject->getAdapter(); return $dbObject->getAdapter();
} }