本文整理汇总了PHP中Zend\Db\ResultSet\HydratingResultSet::count方法的典型用法代码示例。如果您正苦于以下问题:PHP HydratingResultSet::count方法的具体用法?PHP HydratingResultSet::count怎么用?PHP HydratingResultSet::count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Db\ResultSet\HydratingResultSet
的用法示例。
在下文中一共展示了HydratingResultSet::count方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: findById
/**
* @param $postId int
*
* @return Post|null
*/
public function findById($postId)
{
$sql = new \Zend\Db\Sql\Sql($this->adapter);
$select = $sql->select();
$select->columns(array('id', 'title', 'slug', 'content', 'created'))->from(array('p' => 'news'))->join(array('c' => 'category'), 'c.id = p.category_id', array('category_id' => 'id', 'name', 'category_slug' => 'slug'), $select::JOIN_INNER)->where(array('p.id' => $postId));
$statement = $sql->prepareStatementForSqlObject($select);
$results = $statement->execute();
$hydrator = new AggregateHydrator();
$hydrator->add(new PostHydrator());
$hydrator->add(new CategoryHydrator());
$resultSet = new HydratingResultSet($hydrator, new Post());
$resultSet->initialize($results);
return $resultSet->count() > 0 ? $resultSet->current() : null;
}
示例2: fetchThumbArr
public function fetchThumbArr($offset, $limit)
{
$select = $this->sql->select();
//$select->where(array('media_url IS NOT NULL'));
$select->where(array('unpublish' => 0));
$select->order('id DESC');
$select->offset($offset);
$select->limit($limit);
$str = $select->getSqlString($this->dbAdapter->getPlatform());
$statement = $this->sql->prepareStatementForSqlObject($select);
$result = $statement->execute();
if ($result->count() == 0) {
return false;
}
$hydrator = new ClassMethods();
$resultSet = new HydratingResultSet($hydrator, new VideosEntity());
$resultSet->initialize($result);
$resultSet->buffer();
$thumbArr = array();
$showNextPageLink = 0;
$key = 0;
foreach ($resultSet as $key => $obj) {
$thumbArr[$key]['thumb'] = $obj->getThumbnail();
$thumbArr[$key]['id'] = $obj->getId();
$thumbArr[$key]['title'] = $obj->getTitle();
$thumbArr[$key]['video_id'] = $obj->getVideoId();
$dateYMon = date("Y-M", strtotime($obj->getDateCreated()));
$thumbArr[$key]['dateYMon'] = $dateYMon;
}
if ($limit == $resultSet->count()) {
$showNextPageLink = 1;
}
$key++;
$thumbArr[$key]['nav']['showNextPageLink'] = $showNextPageLink;
$thumbArr[$key]['nav']['page'] = $offset / $limit;
$thumbArr[$key]['nav']['limit'] = $limit;
return $thumbArr;
}
示例3: getRecentCategory
public function getRecentCategory($catId, $offset, $numCols)
{
$q = "SELECT `blvd`.*, `blvd_categories`.`category_id` AS `category_id` FROM `blvd` ";
$q .= "INNER JOIN `blvd_categories` ON (`blvd_categories`.`blvd_id` = `blvd`.`id` AND blvd_categories.category_id = ?) ";
$q .= "INNER JOIN categories ON (blvd_categories.category_id = categories.id) ";
$q .= "WHERE blvd_categories.primary = 1 ";
$q .= "AND categories.top = 1 ";
$q .= "AND `categories`.`disabled` = '0' ";
$q .= "ORDER BY `category_id` DESC, `last_social_media_datetime` DESC, blvd_id DESC ";
$q .= "LIMIT ?, 1";
$statement = $this->dbAdapter->createStatement($q, array($catId, $offset));
$result = $statement->execute();
$hydrator = new ClassMethods();
$resultSet = new HydratingResultSet($hydrator, new BlvdModel());
$resultSet->initialize($result);
if ($resultSet->count() == 0) {
return false;
}
$resultSet->buffer();
$resultSet = $this->addSocialMedia($resultSet, $numCols);
$resultSet = $this->addSecondaryCategory($resultSet);
return $resultSet;
}
示例4: fetchThumbArr
public function fetchThumbArr($dateYMon, $offset, $limit, $prevDateYMon, $nextDateYMon, $prevTotal)
{
$select = $this->sql->select();
$dateUt = mktime(0, 0, 0, date("m", strtotime($dateYMon)), 1, date("Y", strtotime($dateYMon)));
$select->where(array("unpublish=0", "date_inserted >= '" . date("Y-m-d 00:00:00", $dateUt) . "'"));
$year = date("Y", strtotime($dateYMon));
$month = date("m", strtotime($dateYMon));
$daysInMonth = cal_days_in_month(CAL_GREGORIAN, $month, $year);
$dateUt = mktime(0, 0, 0, $month, $daysInMonth, $year);
$select->where(array("date_inserted <= '" . date("Y-m-d 23:59:59", $dateUt) . "'"));
$select->where(array('media_url IS NOT NULL'));
$select->order('id DESC');
$select->offset($offset);
$select->limit($limit);
$str = $select->getSqlString($this->dbAdapter->getPlatform());
$statement = $this->sql->prepareStatementForSqlObject($select);
$result = $statement->execute();
if ($result->count() == 0) {
// if the date being requested is today's date and their are no results, return false so as to retry with previous month
return false;
}
$hydrator = new ClassMethods();
$resultSet = new HydratingResultSet($hydrator, new GalleryModel());
$resultSet->initialize($result);
$resultSet->buffer();
$thumbArr = array();
$dateNowYM = date("Y-M");
$dateNextYM = 0;
$showNextPageLink = 0;
$showNextMonthLink = 0;
$key = 0;
foreach ($resultSet as $key => $obj) {
$thumbArr[$key]['thumb'] = $obj->getThumb();
$thumbArr[$key]['id'] = $obj->getId();
$dateYMon = date("Y-M", strtotime($obj->getDateInserted()));
$thumbArr[$key]['dateYMon'] = $dateYMon;
}
if ($limit == $resultSet->count()) {
// TODO readjust query to get from first of next month in where clause, and if first of next month is returned, showNextMonthLink instead
$showNextPageLink = 1;
} elseif ($nextDateYMon != 0) {
$showNextMonthLink = 1;
}
$key++;
$thumbArr[$key]['nav']['dateYMon'] = $dateYMon;
$thumbArr[$key]['nav']['prevDateYMon'] = $prevDateYMon;
$thumbArr[$key]['nav']['nextDateYMon'] = $nextDateYMon;
$thumbArr[$key]['nav']['showNextPageLink'] = $showNextPageLink;
$thumbArr[$key]['nav']['showNextMonthLink'] = $showNextMonthLink;
$thumbArr[$key]['nav']['page'] = $offset / $limit;
$maxPage = floor($prevTotal / $limit);
$thumbArr[$key]['nav']['prevMaxPage'] = $maxPage;
$thumbArr[$key]['nav']['limit'] = $limit;
return $thumbArr;
}