本文整理匯總了PHP中Doctrine_Query::groupBy方法的典型用法代碼示例。如果您正苦於以下問題:PHP Doctrine_Query::groupBy方法的具體用法?PHP Doctrine_Query::groupBy怎麽用?PHP Doctrine_Query::groupBy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Doctrine_Query
的用法示例。
在下文中一共展示了Doctrine_Query::groupBy方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: gallery
/**
* @param $filter
*/
protected function gallery($filter)
{
if (!$this->_gallery_added) {
$this->_query->leftJoin('f.Slices s');
$this->_query->groupBy('f.id');
$this->_gallery_added = true;
}
switch ($filter->operator) {
case 'is':
$s = $this->_slice_alias_count++;
$this->_query->andWhere('f.id in (SELECT s' . $s . '.file_id FROM RokGallery_Model_Slice s' . $s . ' where s' . $s . '.gallery_id = ? GROUP BY s' . $s . '.file_id)', $filter->query);
$this->_query->andWhere('s.gallery_id = ?', $filter->query);
break;
default:
}
}
示例2: queryTagsWithCountsByModel
/**
* Retrieves tags with the number of taggings for a given set of models, can be accessed using ->$model
*
* @param Array $models
* @param Doctrine_Query $q
* @return Doctrine_Query
*/
public function queryTagsWithCountsByModel($models, $q = null)
{
$q->leftJoin('r.Tagging tg')->addSelect('r.*');
foreach ($models as $model) {
$q->addSelect("SUM(IF(tg.taggable_model = '{$model}' , 1, 0)) AS " . $model . "Count");
}
$q->groupBy('r.id');
return $q;
}
示例3: 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());
}