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


PHP ResultSet::count方法代码示例

本文整理汇总了PHP中Zend\Db\ResultSet\ResultSet::count方法的典型用法代码示例。如果您正苦于以下问题:PHP ResultSet::count方法的具体用法?PHP ResultSet::count怎么用?PHP ResultSet::count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\Db\ResultSet\ResultSet的用法示例。


在下文中一共展示了ResultSet::count方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: count

 /**
  * Countable: return count of rows
  *
  * @return int
  */
 public function count()
 {
     if ($this->count === null) {
         $this->count = $this->dataSource->count();
     }
     return $this->count;
 }
开发者ID:robocoder,项目名称:solublecomponents,代码行数:12,代码来源:ResultSet.php

示例2: testCountReturnsCountOfRows

 public function testCountReturnsCountOfRows()
 {
     $count = rand(3, 75);
     $dataSource = $this->getArrayDataSource($count);
     $this->resultSet->initialize($dataSource);
     $this->assertEquals($count, $this->resultSet->count());
 }
开发者ID:razvansividra,项目名称:pnlzf2-1,代码行数:7,代码来源:ResultSetIntegrationTest.php

示例3: getProductJoinedRow

 /**
  * Get joined product
  * 
  * @param int $id product id
  * @return ProductJoinedRow
  * @throws Exception\InvalidArgumentException
  */
 public function getProductJoinedRow($id)
 {
     $id = (int) $id;
     $pt = $this->getJoinedTable('ProductTable')->getTable();
     $pdt = $this->getJoinedTable('ProductDescriptionTable')->getTable();
     $select = $this->sql->select()->from("{$pt}")->columns(array("*"))->join($pdt, "{$pt}.product_id = {$pdt}.product_id", array('description_id', 'description'), Select::JOIN_LEFT)->order("{$pt}.product_id DESC")->where("{$pt}.product_id = {$id}");
     $statement = $this->sql->prepareStatementForSqlObject($select);
     $resultSet = new ResultSet(ResultSet::TYPE_ARRAYOBJECT, new ProductJoinedRow());
     $resultSet->initialize($statement->execute());
     if (!$resultSet->count()) {
         throw new Exception\InvalidArgumentException("Not found joined product: {$id}");
     }
     return $resultSet->current();
 }
开发者ID:ashimidashajia,项目名称:zendstore,代码行数:21,代码来源:ProductJoinedTable.php

示例4: checkModuleStructurePages

 /**
  * Check modules structure pages
  *
  * @param string $module
  * @return boolean
  */
 public function checkModuleStructurePages($module)
 {
     $select = $this->select();
     $select->from(['a' => 'application_module'])->columns([])->join(['b' => 'page_system'], 'a.id = b.module', [])->join(['c' => 'page_structure'], 'b.id = c.system_page', ['id'])->where(['name' => $module])->limit(1);
     $statement = $this->prepareStatementForSqlObject($select);
     $resultSet = new ResultSet();
     $resultSet->initialize($statement->execute());
     $result = $resultSet->count() ? true : false;
     // load the module's translations
     if (true === $result) {
         $module = $this->getModuleInfo($module);
         if ($module['type'] == self::MODULE_TYPE_CUSTOM && $module['status'] == self::MODULE_STATUS_NOT_ACTIVE) {
             $this->addModuleTranslations($this->getSystemModuleConfig($module['name'], false));
         }
     }
     return $result;
 }
开发者ID:esase,项目名称:dream-cms,代码行数:23,代码来源:ApplicationModuleAdministration.php

示例5: getAllAttributeIds

 /**
  * Get all the attributes ids from the group attributes Idx
  * 
  * @param \Zend\Db\ResultSet\ResultSet $records
  * @return array
  */
 public function getAllAttributeIds(\Zend\Db\ResultSet\ResultSet $records)
 {
     $ids = array();
     if ($records->count()) {
         foreach ($records as $record) {
             $ids[] = $record->attribute_id;
         }
     }
     return $ids;
 }
开发者ID:eotg1910,项目名称:shineisp2,代码行数:16,代码来源:ProductAttributeGroupService.php

示例6: setEntities

 public function setEntities(ResultSet $oResultSet)
 {
     $aEntities = array();
     if ($oResultSet->count()) {
         foreach ($oResultSet as $oRow) {
             foreach ($oRow as $sKey => $sValue) {
                 $oRow->{$sKey} = $this->getTranslatedValue($sKey, $sValue);
             }
             $oEntity = $this->createNewEntity();
             $oEntity->setOptions($oRow);
             $aEntities[] = $oEntity;
         }
     }
     return $aEntities;
 }
开发者ID:lstaszak,项目名称:zf2main,代码行数:15,代码来源:NativeRepositoryAbstract.php

示例7: init

 public function init($params, $table, $whereSql = '')
 {
     $result['draw'] = (int) $params['draw'];
     $columns = $this->_extractColumns($params);
     $sql = new Sql($this->adapterDb);
     $where = new Where();
     $select = $sql->select()->from($table)->columns(array('total' => new Expression('COUNT(*)')));
     if ($whereSql) {
         $where->literal($whereSql);
         $select->where($where);
     }
     $statement = $sql->prepareStatementForSqlObject($select);
     $resultsSql = $statement->execute();
     $result['recordsTotal'] = (int) $resultsSql->current()['total'];
     $select = $sql->select()->from($table)->columns($columns);
     $globalSearch = [];
     if ($search = $params['search']['value']) {
         foreach ($columns as $col) {
             $globalSearch[] = "`{$col}` LIKE '%{$search}%'";
         }
     }
     if (!empty($globalSearch)) {
         $globalSearchSql = implode(' OR ', $globalSearch);
         $where->literal("({$globalSearchSql})");
     }
     $columnSearch = [];
     foreach ($params['columns'] as $index => $column) {
         if ($column['search']['value']) {
             if ($params['search']['regex'] == 'false') {
                 $columnSearch[] = "`{$columns[$index]}` LIKE '%{$column['search']['value']}%'";
             } else {
                 $columnSearch[] = "`{$columns[$index]}` = '{$column['search']['value']}'";
             }
         }
     }
     if (!empty($columnSearch)) {
         $columnSearchSql = implode(' AND ', $columnSearch);
         $where->literal("({$columnSearchSql})");
     }
     if ($whereSql) {
         $where->literal($whereSql);
     }
     $select->where($where);
     if (isset($params['order'])) {
         $arrayOrder = [];
         foreach ($params['order'] as $order) {
             $arrayOrder[$columns[$order['column']]] = $order['dir'];
         }
         $select->order($arrayOrder);
     }
     //        die($select->getSqlString());
     $statement = $sql->prepareStatementForSqlObject($select);
     $resultsSql = $statement->execute();
     $resultSet = new ResultSet();
     $resultSet->initialize($resultsSql);
     $result['recordsFiltered'] = (int) $resultSet->count();
     $dbSelect = new DbSelect($select, $this->adapterDb);
     $paginator = new Paginator($dbSelect);
     $paginator->setItemCountPerPage($params['length']);
     $paginator->setCurrentPageNumber($params['start'] / $params['length'] + 1);
     $array = [];
     foreach ($paginator as $index => $data) {
         foreach ($data as $value) {
             $array[$index][] = $value;
         }
     }
     $result['data'] = $array;
     $this->data = $result;
     return $this;
 }
开发者ID:diegovarussa,项目名称:data-table,代码行数:70,代码来源:DataTableModel.php

示例8: getCityListAsArray

 /**
  * @param ResultSet|array[] $cities
  * @return array
  */
 private function getCityListAsArray($cities)
 {
     $cityList = ['-- All Cities --'];
     if ($cities->count()) {
         foreach ($cities as $city) {
             $cityList[$city['id']] = $city['name'];
         }
     }
     return $cityList;
 }
开发者ID:arbi,项目名称:MyCode,代码行数:14,代码来源:Charge.php

示例9: count

 /**
  * Countable: return count of rows
  *
  * @return int
  */
 public function count()
 {
     return $this->zfResultSet->count();
 }
开发者ID:robocoder,项目名称:solublecomponents,代码行数:9,代码来源:AbstractResultSet.php

示例10: prepareData

 /**
  * @param \Zend\Db\ResultSet\ResultSet|MoneyAccount[]|\ArrayObject $pspList
  * @return array
  */
 private function prepareData($pspList)
 {
     $data = [];
     if ($pspList->count()) {
         foreach ($pspList as $psp) {
             $router = $this->getEvent()->getRouter();
             $editUrl = $router->assemble(['controller' => 'psp', 'action' => 'edit', 'id' => $psp->getId()], ['name' => 'finance/psp']);
             $status = $psp->getActive() ? '<span class="label label-success">Active</span>' : '<span class="label label-default">Inactive</span>';
             array_push($data, ['<div class="text-center">' . $status . '</div>', $psp->getShortName(), $psp->getName(), $psp->getMoneyAccountName(), $psp->getBatch(), '<a class="btn btn-xs btn-primary" href="' . $editUrl . '" data-html-content="Edit"></a>']);
         }
     }
     return $data;
 }
开发者ID:arbi,项目名称:MyCode,代码行数:17,代码来源:PspController.php

示例11: _createSessionFromResult

 protected function _createSessionFromResult(Db\ResultSet\ResultSet $result)
 {
     if (!$result->count()) {
         return NULL;
     }
     return $this->_arrayToSession((array) $result->current());
 }
开发者ID:ivan-novakov,项目名称:zf2-openid-connect-server-module,代码行数:7,代码来源:MysqlLite.php

示例12: getAnswerTrack

 /**
  * Get answer track
  *
  * @param integer $questionId
  * @return array
  */
 public function getAnswerTrack($questionId)
 {
     $processedData = [];
     $select = $this->select();
     $select->from('poll_answer_track')->columns(['answer_id', 'answer_count' => new Expression('count(answer_id)')])->where(['question_id' => $questionId])->group('answer_id');
     $statement = $this->prepareStatementForSqlObject($select);
     $resultSet = new ResultSet();
     $resultSet->initialize($statement->execute());
     if (!$resultSet->count()) {
         return $processedData;
     }
     // process track data
     foreach ($resultSet as $data) {
         $processedData[$data->answer_id] = $data->answer_count;
     }
     return $processedData;
 }
开发者ID:esase,项目名称:dream-cms-poll-module,代码行数:23,代码来源:PollWidget.php


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