本文整理汇总了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;
}
示例2: testCountReturnsCountOfRows
public function testCountReturnsCountOfRows()
{
$count = rand(3, 75);
$dataSource = $this->getArrayDataSource($count);
$this->resultSet->initialize($dataSource);
$this->assertEquals($count, $this->resultSet->count());
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例9: count
/**
* Countable: return count of rows
*
* @return int
*/
public function count()
{
return $this->zfResultSet->count();
}
示例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;
}
示例11: _createSessionFromResult
protected function _createSessionFromResult(Db\ResultSet\ResultSet $result)
{
if (!$result->count()) {
return NULL;
}
return $this->_arrayToSession((array) $result->current());
}
示例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;
}