diff --git a/lib/Doctrine/Connection.php b/lib/Doctrine/Connection.php index 82041301f..f2e91360f 100644 --- a/lib/Doctrine/Connection.php +++ b/lib/Doctrine/Connection.php @@ -127,6 +127,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun * @see Doctrine_Expression * @see Doctrine_Export * @see Doctrine_Transaction + * @see Doctrine_Connection::$modules all availible modules * @param string $name the name of the module to get * @throws Doctrine_Connection_Exception if trying to get an unknown module * @return Doctrine_Connection_Module connection module diff --git a/lib/Doctrine/Hydrate.php b/lib/Doctrine/Hydrate.php index b84ecdf79..ffcece995 100644 --- a/lib/Doctrine/Hydrate.php +++ b/lib/Doctrine/Hydrate.php @@ -24,14 +24,14 @@ Doctrine::autoload('Doctrine_Access'); * Its purpose is to populate object graphs. * * - * @package Doctrine - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @category Object Relational Mapping - * @link www.phpdoctrine.com - * @since 1.0 - * @version $Revision$ - * @author Konsta Vesterinen - */ + * @package Doctrine + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @category Object Relational Mapping + * @link www.phpdoctrine.com + * @since 1.0 + * @version $Revision$ + * @author Konsta Vesterinen + */ abstract class Doctrine_Hydrate extends Doctrine_Access { /** * @var array $fetchmodes an array containing all fetchmodes @@ -339,7 +339,7 @@ abstract class Doctrine_Hydrate extends Doctrine_Access { array_walk($params, array(__CLASS__, 'convertBoolean')); if( ! $this->view) - $query = $this->getQuery(true); + $query = $this->getQuery($params); else $query = $this->view->getSelectSql(); diff --git a/lib/Doctrine/Query.php b/lib/Doctrine/Query.php index 816cef7a0..e975c2963 100644 --- a/lib/Doctrine/Query.php +++ b/lib/Doctrine/Query.php @@ -466,9 +466,11 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable { /** * returns the built sql query * + * @param array $params an array of prepared statement params (needed only in mysql driver + * when limit subquery algorithm is used) * @return string */ - public function getQuery($executeSubquery = false) { + public function getQuery($params = array()) { if(empty($this->parts["select"]) || empty($this->parts["from"])) return false; @@ -512,15 +514,16 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable { if($needsSubQuery) { $subquery = $this->getLimitSubquery(); - $dbh = $this->connection->getDBH(); - // mysql doesn't support LIMIT in subqueries - switch($dbh->getAttribute(PDO::ATTR_DRIVER_NAME)) { + + switch(strtolower($this->connection->getName())) { case 'mysql': - $list = $dbh->query($subquery)->fetchAll(PDO::FETCH_COLUMN); + // mysql doesn't support LIMIT in subqueries + $list = $this->conn->execute($subquery, $params)->fetchAll(PDO::FETCH_COLUMN); $subquery = implode(', ', $list); break; case 'pgsql': + // pgsql needs special nested LIMIT subquery $subquery = 'SELECT doctrine_subquery_alias.' . $table->getIdentifier(). ' FROM (' . $subquery . ') AS doctrine_subquery_alias'; break; }