1
0
mirror of synced 2025-01-17 22:11:41 +03:00
This commit is contained in:
zYne 2006-10-26 23:05:55 +00:00
parent 53bdc31ad5
commit dd73f6de4a
2 changed files with 12 additions and 6 deletions

View File

@ -488,12 +488,18 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
$dbh = $this->connection->getDBH();
// mysql doesn't support LIMIT in subqueries
if($dbh->getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql') {
$list = $dbh->query($subquery)->fetchAll(PDO::FETCH_NUM);
switch($dbh->getAttribute(PDO::ATTR_DRIVER_NAME)) {
case 'mysql':
$list = $dbh->query($subquery)->fetchAll(PDO::FETCH_COLUMN);
$subquery = implode(', ', $list);
break;
case 'pgsql':
$subquery = 'SELECT doctrine_subquery_alias.' . $table->getIdentifier(). ' FROM (' . $subquery . ') AS doctrine_subquery_alias';
break;
}
$field = $table->getTableName().'.'.$table->getIdentifier();
array_unshift($this->parts['where'], $field.' IN ('.$subquery.')');
array_unshift($this->parts['where'], $field. ' IN (' . $subquery . ')');
$modifyLimit = false;
}
}
@ -550,7 +556,7 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
$subquery .= ( ! empty($this->parts['groupby']))? ' GROUP BY ' . implode(', ',$this->parts['groupby']):'';
$subquery .= ( ! empty($this->parts['having']))? ' HAVING ' . implode(' ',$this->parts['having']):'';
$subquery .= ( ! empty($this->parts['orderby']))? ' ORDER BY ' . implode(' ', $this->parts['orderby']):'';
// add driver specific limit clause
$subquery = $this->connection->modifyLimitQuery($subquery, $this->parts['limit'], $this->parts['offset']);

View File

@ -63,7 +63,7 @@ error_reporting(E_ALL);
print '<pre>';
$test = new GroupTest('Doctrine Framework Unit Tests');
/**
$test->addTestCase(new Doctrine_DataDict_Pgsql_TestCase());
$test->addTestCase(new Doctrine_Relation_TestCase());
@ -147,7 +147,7 @@ $test->addTestCase(new Doctrine_Query_Select_TestCase());
$test->addTestCase(new Doctrine_Query_Delete_TestCase());
$test->addTestCase(new Doctrine_Query_Update_TestCase());
*/
$test->addTestCase(new Doctrine_Query_Limit_TestCase());