本文整理汇总了PHP中SQLQuery::setGroupBy方法的典型用法代码示例。如果您正苦于以下问题:PHP SQLQuery::setGroupBy方法的具体用法?PHP SQLQuery::setGroupBy怎么用?PHP SQLQuery::setGroupBy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SQLQuery
的用法示例。
在下文中一共展示了SQLQuery::setGroupBy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: join
/**
* Add a join clause to this query
* @deprecated 3.0 Use innerJoin() or leftJoin() instead.
*/
public function join($join)
{
Deprecation::notice('3.0', 'Use innerJoin() or leftJoin() instead.');
if ($join) {
$this->query->addFrom($join);
// TODO: This needs to be resolved for all databases
if (DB::getConn() instanceof MySQLDatabase) {
$from = $this->query->getFrom();
$this->query->setGroupBy(reset($from) . ".\"ID\"");
}
}
return $this;
}
示例2: testOrderByContainingAggregateAndLimitOffset
/**
* Test that "_SortColumn0" is added for an aggregate in the ORDER BY
* clause, in combination with a LIMIT and GROUP BY clause.
* For some databases, like MSSQL, this is a complicated scenario
* because a subselect needs to be done to query paginated data.
*/
public function testOrderByContainingAggregateAndLimitOffset()
{
$query = new SQLQuery();
$query->setSelect(array('"Name"', '"Meta"'));
$query->setFrom('"SQLQueryTest_DO"');
$query->setOrderBy(array('MAX("Date")'));
$query->setGroupBy(array('"Name"', '"Meta"'));
$query->setLimit('1', '1');
$records = array();
foreach ($query->execute() as $record) {
$records[] = $record;
}
$this->assertCount(1, $records);
$this->assertEquals('Object 2', $records[0]['Name']);
$this->assertEquals('2012-05-01 09:00:00', $records['0']['_SortColumn0']);
}