Commit 92b395cf authored by jwage's avatar jwage

[2.0] Removing last few dependencies on 2.0

parent a6fbc199
...@@ -28,6 +28,7 @@ namespace Doctrine\Common; ...@@ -28,6 +28,7 @@ namespace Doctrine\Common;
* information to an event handler when an event is raised. The single empty EventArgs * information to an event handler when an event is raised. The single empty EventArgs
* instance can be obtained through {@link getEmptyInstance()}. * instance can be obtained through {@link getEmptyInstance()}.
* *
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Roman Borschel * @author Roman Borschel
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org * @link www.doctrine-project.org
......
...@@ -72,6 +72,15 @@ class Connection ...@@ -72,6 +72,15 @@ class Connection
*/ */
const TRANSACTION_SERIALIZABLE = 4; 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. * The wrapped driver connection.
* *
...@@ -280,7 +289,7 @@ class Connection ...@@ -280,7 +289,7 @@ class Connection
*/ */
public function fetchRow($statement, array $params = array()) 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 ...@@ -292,7 +301,7 @@ class Connection
*/ */
public function fetchArray($statement, array $params = array()) 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 ...@@ -305,7 +314,7 @@ class Connection
*/ */
public function fetchColumn($statement, array $params = array(), $colnum = 0) 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 ...@@ -327,7 +336,7 @@ class Connection
*/ */
public function fetchBoth($statement, array $params = array()) 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 ...@@ -498,7 +507,7 @@ class Connection
*/ */
public function fetchAll($sql, array $params = array()) 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);
} }
/** /**
......
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
namespace Doctrine\DBAL\Driver\PDOMySql; namespace Doctrine\DBAL\Driver\PDOMySql;
use Doctrine\DBAL\Connection;
/** /**
* PDO MySql driver. * PDO MySql driver.
* *
...@@ -45,7 +47,7 @@ class Driver implements \Doctrine\DBAL\Driver ...@@ -45,7 +47,7 @@ class Driver implements \Doctrine\DBAL\Driver
$password, $password,
$driverOptions $driverOptions
); );
$conn->setAttribute(\PDO::ATTR_AUTOCOMMIT, false); $conn->setAttribute(Connection::ATTR_AUTOCOMMIT, false);
return $conn; return $conn;
} }
......
...@@ -21,9 +21,9 @@ ...@@ -21,9 +21,9 @@
namespace Doctrine\ORM\Internal\Hydration; namespace Doctrine\ORM\Internal\Hydration;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Type;
use Doctrine\Common\DoctrineException; use Doctrine\Common\DoctrineException;
use \PDO;
/** /**
* Base class for all hydrators. A hydrator is a class that provides some form * Base class for all hydrators. A hydrator is a class that provides some form
...@@ -104,7 +104,7 @@ abstract class AbstractHydrator ...@@ -104,7 +104,7 @@ abstract class AbstractHydrator
*/ */
public function hydrateRow() public function hydrateRow()
{ {
$row = $this->_stmt->fetch(PDO::FETCH_ASSOC); $row = $this->_stmt->fetch(Connection::FETCH_ASSOC);
if ( ! $row) { if ( ! $row) {
$this->_cleanup(); $this->_cleanup();
return false; return false;
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
namespace Doctrine\ORM\Internal\Hydration; namespace Doctrine\ORM\Internal\Hydration;
use \PDO; use Doctrine\DBAL\Connection;
/** /**
* Description of ArrayHydrator * Description of ArrayHydrator
...@@ -57,7 +57,7 @@ class ArrayHydrator extends AbstractHydrator ...@@ -57,7 +57,7 @@ class ArrayHydrator extends AbstractHydrator
{ {
$result = array(); $result = array();
$cache = array(); $cache = array();
while ($data = $this->_stmt->fetch(PDO::FETCH_ASSOC)) { while ($data = $this->_stmt->fetch(Connection::FETCH_ASSOC)) {
$this->_hydrateRow($data, $cache, $result); $this->_hydrateRow($data, $cache, $result);
} }
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
namespace Doctrine\ORM\Internal\Hydration; namespace Doctrine\ORM\Internal\Hydration;
use \PDO; use Doctrine\DBAL\Connection;
use Doctrine\ORM\PersistentCollection; use Doctrine\ORM\PersistentCollection;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
...@@ -116,7 +116,7 @@ class ObjectHydrator extends AbstractHydrator ...@@ -116,7 +116,7 @@ class ObjectHydrator extends AbstractHydrator
$result = $this->_rsm->isMixed ? array() : new Collection; $result = $this->_rsm->isMixed ? array() : new Collection;
$cache = array(); $cache = array();
while ($data = $this->_stmt->fetch(PDO::FETCH_ASSOC)) { while ($data = $this->_stmt->fetch(Connection::FETCH_ASSOC)) {
$this->_hydrateRow($data, $cache, $result); $this->_hydrateRow($data, $cache, $result);
} }
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
namespace Doctrine\ORM\Internal\Hydration; namespace Doctrine\ORM\Internal\Hydration;
use \PDO; use Doctrine\DBAL\Connection;
/** /**
* Hydrator that produces flat, rectangular results of scalar data. * Hydrator that produces flat, rectangular results of scalar data.
...@@ -38,7 +38,7 @@ class ScalarHydrator extends AbstractHydrator ...@@ -38,7 +38,7 @@ class ScalarHydrator extends AbstractHydrator
{ {
$result = array(); $result = array();
$cache = array(); $cache = array();
while ($data = $this->_stmt->fetch(PDO::FETCH_ASSOC)) { while ($data = $this->_stmt->fetch(Connection::FETCH_ASSOC)) {
$result[] = $this->_gatherScalarRowData($data, $cache); $result[] = $this->_gatherScalarRowData($data, $cache);
} }
return $result; return $result;
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
namespace Doctrine\ORM\Internal\Hydration; namespace Doctrine\ORM\Internal\Hydration;
use \PDO; use Doctrine\DBAL\Connection;
/** /**
* Description of SingleScalarHydrator * Description of SingleScalarHydrator
...@@ -34,7 +34,7 @@ class SingleScalarHydrator extends AbstractHydrator ...@@ -34,7 +34,7 @@ class SingleScalarHydrator extends AbstractHydrator
protected function _hydrateAll() protected function _hydrateAll()
{ {
$cache = array(); $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 //TODO: Let this exception be raised by Query as QueryException
if (count($result) > 1 || count($result[0]) > 1) { if (count($result) > 1 || count($result[0]) > 1) {
throw HydrationException::nonUniqueResult(); throw HydrationException::nonUniqueResult();
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
namespace Doctrine\ORM\Persisters; namespace Doctrine\ORM\Persisters;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Type;
use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManager;
use Doctrine\ORM\UnitOfWork; use Doctrine\ORM\UnitOfWork;
...@@ -339,7 +340,7 @@ class StandardEntityPersister ...@@ -339,7 +340,7 @@ class StandardEntityPersister
$stmt = $this->_conn->prepare($this->_getSelectSingleEntitySql($criteria)); $stmt = $this->_conn->prepare($this->_getSelectSingleEntitySql($criteria));
$stmt->execute(array_values($criteria)); $stmt->execute(array_values($criteria));
$data = array(); $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]; $fieldName = $this->_class->fieldNames[$column];
$data[$fieldName] = Type::getType($this->_class->getTypeOfField($fieldName)) $data[$fieldName] = Type::getType($this->_class->getTypeOfField($fieldName))
->convertToPHPValue($value); ->convertToPHPValue($value);
......
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