本文整理汇总了PHP中Doctrine_Query::count方法的典型用法代码示例。如果您正苦于以下问题:PHP Doctrine_Query::count方法的具体用法?PHP Doctrine_Query::count怎么用?PHP Doctrine_Query::count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine_Query
的用法示例。
在下文中一共展示了Doctrine_Query::count方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: count
/**
* Count results
*
* @return int
*/
public function count()
{
if ($this->_rowCount === null) {
$this->_rowCount = $this->_query->count();
}
return $this->_rowCount;
}
示例2: getTotalRecords
/**
* Return the total of records
*
* @return integer
*/
public function getTotalRecords()
{
if ($this->_totalRecords > 0) {
return $this->_totalRecords;
}
return (int) $this->_query->count();
}
示例3: count
public function count($params = array())
{
$breadcrumb = $this->getBreadcrumb();
$result = parent::count($params);
$this->restoreBreadcrumb($breadcrumb);
return $result;
}
示例4: getTotalRecords
/**
* Return the total of records
*
* @return integer
*/
public function getTotalRecords()
{
return (int) $this->_query->count();
}
示例5: getRecords
/**
* getRecords
* Get records from the DB
* @return mixed
*/
public function getRecords(Doctrine_Query $dq, $currentPage = 1, $rowNum = 2, array $sort = array(), array $where = array())
{
$uri = "";
$module = Zend_Controller_Front::getInstance()->getRequest()->getModuleName();
$controller = Zend_Controller_Front::getInstance()->getRequest()->getControllerName();
// Defining the url sort
if (!empty($sort)) {
foreach ($sort as $s) {
$arrSort[] = "/sort/" . str_replace(" ", ",", $s);
}
$arrSort = array_unique($arrSort);
$uri = implode("", $arrSort);
}
$pagerLayout = new Doctrine_Pager_Layout(new Doctrine_Pager($dq, $currentPage, $rowNum), new Doctrine_Pager_Range_Sliding(array('chunk' => 10)), "/{$module}/{$controller}/list/page/{%page_number}" . $uri);
// Get the pager object
$pager = $pagerLayout->getPager();
// Set the Order criteria
if (!empty($sort)) {
$pager->getQuery()->orderBy(implode(", ", $sort));
}
if (isset($where) && is_array($where)) {
foreach ($where as $filters) {
if (isset($filters[0]) && is_array($filters[0])) {
foreach ($filters as $filter) {
$method = $filter['method'];
$value = $filter['value'];
$criteria = $filter['criteria'];
$pager->getQuery()->{$method}($criteria, $value);
}
} else {
$method = $filters['method'];
$value = $filters['value'];
$criteria = $filters['criteria'];
$pager->getQuery()->{$method}($criteria, $value);
}
}
}
$pagerLayout->setTemplate('<a href="{%url}">{%page}</a> ');
$pagerLayout->setSelectedTemplate('<a class="active" href="{%url}">{%page}</a> ');
$this->data = $pagerLayout->execute(array(), Doctrine_Core::HYDRATE_ARRAY);
$this->paging = $pagerLayout->display(null, true);
$this->recordcount = $dq->count();
#print_r ( $this->data );
return $this;
}
示例6: testAggregateFunctionsInOrderByAndHavingWithCount
public function testAggregateFunctionsInOrderByAndHavingWithCount()
{
$q = new Doctrine_Query();
$q->select('u.*, COUNT(a.id) num_albums')
->from('User u')
->leftJoin('u.Album a')
->orderby('num_albums desc')
->groupby('u.id')
->having('num_albums > 0')
->limit(5);
try {
$q->count();
$this->pass();
} catch (Doctrine_Exception $e) {
$this->fail();
}
}
示例7: testCountWithGroupBy
public function testCountWithGroupBy()
{
$q = new Doctrine_Query();
$q->from('User u');
$q->leftJoin('u.Phonenumber p');
$q->groupBy('p.entity_id');
$this->assertEqual($q->count(), $q->execute()->count());
}
示例8: testAggregateFunctionsInOrderByAndHavingWithCount
public function testAggregateFunctionsInOrderByAndHavingWithCount()
{
$q = new Doctrine_Query();
$q->select('u.*, COUNT(a.id) num_albums')->from('User u')->leftJoin('u.Album a')->orderby('num_albums desc')->groupby('u.id')->having('num_albums > 0')->limit(5);
try {
$this->assertEqual($q->getCountQuery(), 'SELECT COUNT(*) AS num_results FROM (SELECT e.id, COUNT(a.id) AS a__0 FROM entity e LEFT JOIN album a ON e.id = a.user_id WHERE e.type = 0 GROUP BY e.id HAVING a__0 > 0) dctrn_count_query');
$q->count();
$this->pass();
} catch (Doctrine_Exception $e) {
$this->fail($e->getMessage());
}
}
示例9: rec_query_total
/**
* Get total from a Doctrine_Query object.
*
* @param Doctrine_Query $q
* @return int $total
*/
protected function rec_query_total(Doctrine_Query $q)
{
return $q->count();
}
示例10: count
/**
* Get the item count
*
* @return integer
*/
public function count()
{
return $this->_query->count();
}