From 32806de819ec097fd1bbeab63d2632af5e4fa449 Mon Sep 17 00:00:00 2001 From: Jianxuan Li Date: Wed, 14 Jan 2015 00:25:56 +0800 Subject: [PATCH] perfect the paginator service and zend db service,add new functions in review service --- Westdc/Helpers/Paginator.php | 14 +++++++++---- Westdc/Review/Review.php | 32 ++++++++++++++++++++++++++++-- Westdc/Service/ServiceAgent/Db.php | 2 +- 3 files changed, 41 insertions(+), 7 deletions(-) diff --git a/Westdc/Helpers/Paginator.php b/Westdc/Helpers/Paginator.php index 2519f00..4aadcdf 100644 --- a/Westdc/Helpers/Paginator.php +++ b/Westdc/Helpers/Paginator.php @@ -30,10 +30,6 @@ class Paginator implements ServiceManagerAwareInterface{ { $this->serviceManager = $serviceManager; - $this->setPageLimit(); - $this->setPageRange(); - $this->setRoute(); - return $this; } @@ -97,6 +93,16 @@ class Paginator implements ServiceManagerAwareInterface{ { $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)) $data = new ArrayAdapter($data); diff --git a/Westdc/Review/Review.php b/Westdc/Review/Review.php index 6eec2c0..99362ea 100644 --- a/Westdc/Review/Review.php +++ b/Westdc/Review/Review.php @@ -10,6 +10,7 @@ namespace Westdc\Review; use Zend\ServiceManager\ServiceManager; use Zend\ServiceManager\ServiceManagerAwareInterface; use Westdc\EventModel\AbstractEventManager; +use Zend\Db\Sql\Select; class Review extends AbstractEventManager implements ServiceManagerAwareInterface{ @@ -124,10 +125,37 @@ class Review extends AbstractEventManager implements ServiceManagerAwareInterfac {$this->limitSql}"; $rs = $this->db->query($sql); - return $rs->fetchAll(); + return $rs->fetchAll(\PDO::FETCH_ASSOC); }//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); + } /** * 取消评审 diff --git a/Westdc/Service/ServiceAgent/Db.php b/Westdc/Service/ServiceAgent/Db.php index 0792cfe..74fc418 100644 --- a/Westdc/Service/ServiceAgent/Db.php +++ b/Westdc/Service/ServiceAgent/Db.php @@ -14,7 +14,7 @@ class Db { public function getZendDb(){ - $dbObject = new WestdcDb\Db($adapter); + $dbObject = new WestdcDb\Db(); return $dbObject->getAdapter(); }