From 92b395cff2e6acfc9f7d4b6a07b74a644abc3f6d Mon Sep 17 00:00:00 2001 From: jwage Date: Fri, 29 May 2009 15:38:46 +0000 Subject: [PATCH] [2.0] Removing last few dependencies on 2.0 --- lib/Doctrine/Common/EventArgs.php | 1 + lib/Doctrine/DBAL/Connection.php | 19 ++++++++++++++----- lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php | 4 +++- .../Internal/Hydration/AbstractHydrator.php | 4 ++-- .../ORM/Internal/Hydration/ArrayHydrator.php | 4 ++-- .../ORM/Internal/Hydration/ObjectHydrator.php | 4 ++-- .../ORM/Internal/Hydration/ScalarHydrator.php | 4 ++-- .../Hydration/SingleScalarHydrator.php | 4 ++-- .../Persisters/StandardEntityPersister.php | 3 ++- 9 files changed, 30 insertions(+), 17 deletions(-) diff --git a/lib/Doctrine/Common/EventArgs.php b/lib/Doctrine/Common/EventArgs.php index d15760d2b..b5b4ba841 100644 --- a/lib/Doctrine/Common/EventArgs.php +++ b/lib/Doctrine/Common/EventArgs.php @@ -28,6 +28,7 @@ namespace Doctrine\Common; * information to an event handler when an event is raised. The single empty EventArgs * instance can be obtained through {@link getEmptyInstance()}. * + * @author Konsta Vesterinen * @author Roman Borschel * @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @link www.doctrine-project.org diff --git a/lib/Doctrine/DBAL/Connection.php b/lib/Doctrine/DBAL/Connection.php index 50792f04e..a8bff9b1b 100644 --- a/lib/Doctrine/DBAL/Connection.php +++ b/lib/Doctrine/DBAL/Connection.php @@ -72,6 +72,15 @@ class Connection */ const TRANSACTION_SERIALIZABLE = 4; + /** + * Derived PDO constants + */ + const FETCH_ASSOC = 2; + const FETCH_BOTH = 4; + const FETCH_COLUMN = 7; + const FETCH_NUM = 3; + const ATTR_AUTOCOMMIT = 0; + /** * The wrapped driver connection. * @@ -280,7 +289,7 @@ class Connection */ public function fetchRow($statement, array $params = array()) { - return $this->execute($statement, $params)->fetch(\PDO::FETCH_ASSOC); + return $this->execute($statement, $params)->fetch(Connection::FETCH_ASSOC); } /** @@ -292,7 +301,7 @@ class Connection */ public function fetchArray($statement, array $params = array()) { - return $this->execute($statement, $params)->fetch(\PDO::FETCH_NUM); + return $this->execute($statement, $params)->fetch(Connection::FETCH_NUM); } /** @@ -305,7 +314,7 @@ class Connection */ public function fetchColumn($statement, array $params = array(), $colnum = 0) { - return $this->execute($statement, $params)->fetchAll(\PDO::FETCH_COLUMN, $colnum); + return $this->execute($statement, $params)->fetchAll(Connection::FETCH_COLUMN, $colnum); } /** @@ -327,7 +336,7 @@ class Connection */ public function fetchBoth($statement, array $params = array()) { - return $this->execute($statement, $params)->fetchAll(\PDO::FETCH_BOTH); + return $this->execute($statement, $params)->fetchAll(Connection::FETCH_BOTH); } /** @@ -498,7 +507,7 @@ class Connection */ public function fetchAll($sql, array $params = array()) { - return $this->execute($sql, $params)->fetchAll(\PDO::FETCH_ASSOC); + return $this->execute($sql, $params)->fetchAll(Connection::FETCH_ASSOC); } /** diff --git a/lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php b/lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php index 328b7a789..0209c1821 100644 --- a/lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php +++ b/lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php @@ -21,6 +21,8 @@ namespace Doctrine\DBAL\Driver\PDOMySql; +use Doctrine\DBAL\Connection; + /** * PDO MySql driver. * @@ -45,7 +47,7 @@ class Driver implements \Doctrine\DBAL\Driver $password, $driverOptions ); - $conn->setAttribute(\PDO::ATTR_AUTOCOMMIT, false); + $conn->setAttribute(Connection::ATTR_AUTOCOMMIT, false); return $conn; } diff --git a/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php index 823700aff..4127a9626 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php @@ -21,9 +21,9 @@ namespace Doctrine\ORM\Internal\Hydration; +use Doctrine\DBAL\Connection; use Doctrine\DBAL\Types\Type; use Doctrine\Common\DoctrineException; -use \PDO; /** * Base class for all hydrators. A hydrator is a class that provides some form @@ -104,7 +104,7 @@ abstract class AbstractHydrator */ public function hydrateRow() { - $row = $this->_stmt->fetch(PDO::FETCH_ASSOC); + $row = $this->_stmt->fetch(Connection::FETCH_ASSOC); if ( ! $row) { $this->_cleanup(); return false; diff --git a/lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php index 8f1a0306e..6b5396f73 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php @@ -21,7 +21,7 @@ namespace Doctrine\ORM\Internal\Hydration; -use \PDO; +use Doctrine\DBAL\Connection; /** * Description of ArrayHydrator @@ -57,7 +57,7 @@ class ArrayHydrator extends AbstractHydrator { $result = array(); $cache = array(); - while ($data = $this->_stmt->fetch(PDO::FETCH_ASSOC)) { + while ($data = $this->_stmt->fetch(Connection::FETCH_ASSOC)) { $this->_hydrateRow($data, $cache, $result); } diff --git a/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php index 698ce163b..2716e5397 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php @@ -21,7 +21,7 @@ namespace Doctrine\ORM\Internal\Hydration; -use \PDO; +use Doctrine\DBAL\Connection; use Doctrine\ORM\PersistentCollection; use Doctrine\Common\Collections\Collection; @@ -116,7 +116,7 @@ class ObjectHydrator extends AbstractHydrator $result = $this->_rsm->isMixed ? array() : new Collection; $cache = array(); - while ($data = $this->_stmt->fetch(PDO::FETCH_ASSOC)) { + while ($data = $this->_stmt->fetch(Connection::FETCH_ASSOC)) { $this->_hydrateRow($data, $cache, $result); } diff --git a/lib/Doctrine/ORM/Internal/Hydration/ScalarHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/ScalarHydrator.php index 4c8953346..612352406 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/ScalarHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/ScalarHydrator.php @@ -21,7 +21,7 @@ namespace Doctrine\ORM\Internal\Hydration; -use \PDO; +use Doctrine\DBAL\Connection; /** * Hydrator that produces flat, rectangular results of scalar data. @@ -38,7 +38,7 @@ class ScalarHydrator extends AbstractHydrator { $result = array(); $cache = array(); - while ($data = $this->_stmt->fetch(PDO::FETCH_ASSOC)) { + while ($data = $this->_stmt->fetch(Connection::FETCH_ASSOC)) { $result[] = $this->_gatherScalarRowData($data, $cache); } return $result; diff --git a/lib/Doctrine/ORM/Internal/Hydration/SingleScalarHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/SingleScalarHydrator.php index b0e620920..39c401b7a 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/SingleScalarHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/SingleScalarHydrator.php @@ -21,7 +21,7 @@ namespace Doctrine\ORM\Internal\Hydration; -use \PDO; +use Doctrine\DBAL\Connection; /** * Description of SingleScalarHydrator @@ -34,7 +34,7 @@ class SingleScalarHydrator extends AbstractHydrator protected function _hydrateAll() { $cache = array(); - $result = $this->_stmt->fetchAll(PDO::FETCH_ASSOC); + $result = $this->_stmt->fetchAll(Connection::FETCH_ASSOC); //TODO: Let this exception be raised by Query as QueryException if (count($result) > 1 || count($result[0]) > 1) { throw HydrationException::nonUniqueResult(); diff --git a/lib/Doctrine/ORM/Persisters/StandardEntityPersister.php b/lib/Doctrine/ORM/Persisters/StandardEntityPersister.php index 931914909..5fd0e85d0 100644 --- a/lib/Doctrine/ORM/Persisters/StandardEntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/StandardEntityPersister.php @@ -21,6 +21,7 @@ namespace Doctrine\ORM\Persisters; +use Doctrine\DBAL\Connection; use Doctrine\DBAL\Types\Type; use Doctrine\ORM\EntityManager; use Doctrine\ORM\UnitOfWork; @@ -339,7 +340,7 @@ class StandardEntityPersister $stmt = $this->_conn->prepare($this->_getSelectSingleEntitySql($criteria)); $stmt->execute(array_values($criteria)); $data = array(); - foreach ($stmt->fetch(\PDO::FETCH_ASSOC) as $column => $value) { + foreach ($stmt->fetch(Connection::FETCH_ASSOC) as $column => $value) { $fieldName = $this->_class->fieldNames[$column]; $data[$fieldName] = Type::getType($this->_class->getTypeOfField($fieldName)) ->convertToPHPValue($value);