Commit dd73f6de authored by zYne's avatar zYne

Fixes #205

parent 53bdc31a
...@@ -488,12 +488,18 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable { ...@@ -488,12 +488,18 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
$dbh = $this->connection->getDBH(); $dbh = $this->connection->getDBH();
// mysql doesn't support LIMIT in subqueries // mysql doesn't support LIMIT in subqueries
if($dbh->getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql') { switch($dbh->getAttribute(PDO::ATTR_DRIVER_NAME)) {
$list = $dbh->query($subquery)->fetchAll(PDO::FETCH_NUM); 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(); $field = $table->getTableName().'.'.$table->getIdentifier();
array_unshift($this->parts['where'], $field.' IN ('.$subquery.')'); array_unshift($this->parts['where'], $field. ' IN (' . $subquery . ')');
$modifyLimit = false; $modifyLimit = false;
} }
} }
...@@ -550,7 +556,7 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable { ...@@ -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['groupby']))? ' GROUP BY ' . implode(', ',$this->parts['groupby']):'';
$subquery .= ( ! empty($this->parts['having']))? ' HAVING ' . implode(' ',$this->parts['having']):''; $subquery .= ( ! empty($this->parts['having']))? ' HAVING ' . implode(' ',$this->parts['having']):'';
$subquery .= ( ! empty($this->parts['orderby']))? ' ORDER BY ' . implode(' ', $this->parts['orderby']):''; $subquery .= ( ! empty($this->parts['orderby']))? ' ORDER BY ' . implode(' ', $this->parts['orderby']):'';
// add driver specific limit clause // add driver specific limit clause
$subquery = $this->connection->modifyLimitQuery($subquery, $this->parts['limit'], $this->parts['offset']); $subquery = $this->connection->modifyLimitQuery($subquery, $this->parts['limit'], $this->parts['offset']);
......
...@@ -63,7 +63,7 @@ error_reporting(E_ALL); ...@@ -63,7 +63,7 @@ error_reporting(E_ALL);
print '<pre>'; print '<pre>';
$test = new GroupTest('Doctrine Framework Unit Tests'); $test = new GroupTest('Doctrine Framework Unit Tests');
/**
$test->addTestCase(new Doctrine_DataDict_Pgsql_TestCase()); $test->addTestCase(new Doctrine_DataDict_Pgsql_TestCase());
$test->addTestCase(new Doctrine_Relation_TestCase()); $test->addTestCase(new Doctrine_Relation_TestCase());
...@@ -147,7 +147,7 @@ $test->addTestCase(new Doctrine_Query_Select_TestCase()); ...@@ -147,7 +147,7 @@ $test->addTestCase(new Doctrine_Query_Select_TestCase());
$test->addTestCase(new Doctrine_Query_Delete_TestCase()); $test->addTestCase(new Doctrine_Query_Delete_TestCase());
$test->addTestCase(new Doctrine_Query_Update_TestCase()); $test->addTestCase(new Doctrine_Query_Update_TestCase());
*/
$test->addTestCase(new Doctrine_Query_Limit_TestCase()); $test->addTestCase(new Doctrine_Query_Limit_TestCase());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment