本文整理汇总了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());
}