/** * 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; }
/** * 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']); }