当前位置: 首页>>代码示例>>PHP>>正文


PHP HydratingResultSet::count方法代码示例

本文整理汇总了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;
 }
开发者ID:samija,项目名称:Deeplifec4tk,代码行数:19,代码来源:PostRepositoryImpl.php

示例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;
 }
开发者ID:nowarena,项目名称:zf2NowArena,代码行数:38,代码来源:VideosMapper.php

示例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;
 }
开发者ID:nowarena,项目名称:zf2NowArena,代码行数:23,代码来源:BlvdMapper.php

示例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;
 }
开发者ID:nowarena,项目名称:zf2NowArena,代码行数:55,代码来源:GalleryMapper.php


注:本文中的Zend\Db\ResultSet\HydratingResultSet::count方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。