From dea4968a23916453fda88b9ef0088082e1130dca Mon Sep 17 00:00:00 2001 From: subzero2000 Date: Mon, 25 Jun 2007 17:48:44 +0000 Subject: [PATCH] Completes deprecation of Doctrine_Db. Fixes #362. --- lib/Doctrine/Adapter/Mock.php | 2 +- lib/Doctrine/Cache.php | 20 ++++++++++---------- lib/Doctrine/Configurable.php | 14 +++++++++----- lib/Doctrine/Connection/Profiler.php | 10 +++++----- lib/Doctrine/Connection/Statement.php | 4 ++-- lib/Doctrine/Db.php | 2 +- lib/Doctrine/Event.php | 10 ++++++---- lib/Doctrine/Hydrate.php | 2 +- lib/Doctrine/Lib.php | 2 +- lib/Doctrine/Manager.php | 4 ---- lib/Doctrine/Query.php | 2 +- lib/Doctrine/Record.php | 10 +++++----- 12 files changed, 42 insertions(+), 40 deletions(-) diff --git a/lib/Doctrine/Adapter/Mock.php b/lib/Doctrine/Adapter/Mock.php index 3d8dc3cc7..846af11d9 100644 --- a/lib/Doctrine/Adapter/Mock.php +++ b/lib/Doctrine/Adapter/Mock.php @@ -150,7 +150,7 @@ class Doctrine_Adapter_Mock implements Doctrine_Adapter_Interface, Countable { } public function getAttribute($attribute) { - if($attribute == PDO::ATTR_DRIVER_NAME) + if($attribute == Doctrine::ATTR_DRIVER_NAME) return strtolower($this->name); } public function setAttribute($attribute, $value) diff --git a/lib/Doctrine/Cache.php b/lib/Doctrine/Cache.php index 2ff9961bf..44b20e865 100644 --- a/lib/Doctrine/Cache.php +++ b/lib/Doctrine/Cache.php @@ -18,7 +18,7 @@ * and is licensed under the LGPL. For more information, see * . */ -Doctrine::autoload('Doctrine_Db_EventListener'); +Doctrine::autoload('Doctrine_EventListener'); /** * Doctrine_Cache * @@ -31,7 +31,7 @@ Doctrine::autoload('Doctrine_Db_EventListener'); * @since 1.0 * @version $Revision$ */ -class Doctrine_Cache extends Doctrine_Db_EventListener implements Countable, IteratorAggregate +class Doctrine_Cache extends Doctrine_EventListener implements Countable, IteratorAggregate { /** * @var array $_options an array of general caching options @@ -281,14 +281,14 @@ class Doctrine_Cache extends Doctrine_Db_EventListener implements Countable, Ite } /** * onPreQuery - * listens the onPreQuery event of Doctrine_Db + * listens on the Doctrine_Event onPreQuery event * * adds the issued query to internal query stack * and checks if cached element exists * * @return boolean */ - public function onPreQuery(Doctrine_Db_Event $event) + public function onPreQuery(Doctrine_Event $event) { $query = $event->getQuery(); @@ -325,14 +325,14 @@ class Doctrine_Cache extends Doctrine_Db_EventListener implements Countable, Ite } /** * onPreFetch - * listens the onPreFetch event of Doctrine_Db_Statement + * listens the onPreFetch event of Doctrine_Connection_Statement * * advances the internal pointer of cached data and returns * the current element * * @return array */ - public function onPreFetch(Doctrine_Db_Event $event) + public function onPreFetch(Doctrine_Event $event) { $ret = current($this->_data); next($this->_data); @@ -340,26 +340,26 @@ class Doctrine_Cache extends Doctrine_Db_EventListener implements Countable, Ite } /** * onPreFetch - * listens the onPreFetchAll event of Doctrine_Db_Statement + * listens the onPreFetchAll event of Doctrine_Connection_Statement * * returns the current cache data array * * @return array */ - public function onPreFetchAll(Doctrine_Db_Event $event) + public function onPreFetchAll(Doctrine_Event $event) { return $this->_data; } /** * onPreExecute - * listens the onPreExecute event of Doctrine_Db_Statement + * listens the onPreExecute event of Doctrine_Connection_Statement * * adds the issued query to internal query stack * and checks if cached element exists * * @return boolean */ - public function onPreExecute(Doctrine_Db_Event $event) + public function onPreExecute(Doctrine_Event $event) { $query = $event->getQuery(); diff --git a/lib/Doctrine/Configurable.php b/lib/Doctrine/Configurable.php index 6c2a6d3aa..d5237bf8e 100644 --- a/lib/Doctrine/Configurable.php +++ b/lib/Doctrine/Configurable.php @@ -169,8 +169,10 @@ abstract class Doctrine_Configurable /** * addListener * - * @param Doctrine_Db_EventListener_Interface|Doctrine_Overloadable $listener - * @return Doctrine_Db + * @param Doctrine_EventListener_Interface|Doctrine_Overloadable $listener + * @return Doctrine_Connection_Informix|Doctrine_Connection_Mssql|Doctrine_Connection_Oracle| + * Doctrine_Connection_Db2|Doctrine_Connection_Firebird|Doctrine_Connection_Common| + * Doctrine_Manager|Doctrine_Connection|Doctrine_Table */ public function addListener($listener, $name = null) { @@ -186,7 +188,7 @@ abstract class Doctrine_Configurable /** * getListener * - * @return Doctrine_Db_EventListener_Interface|Doctrine_Overloadable + * @return Doctrine_EventListener_Interface|Doctrine_Overloadable */ public function getListener() { @@ -201,8 +203,10 @@ abstract class Doctrine_Configurable /** * setListener * - * @param Doctrine_Db_EventListener_Interface|Doctrine_Overloadable $listener - * @return Doctrine_Db + * @param Doctrine_EventListener_Interface|Doctrine_Overloadable $listener + * @return Doctrine_Connection_Informix|Doctrine_Connection_Mssql|Doctrine_Connection_Oracle| + * Doctrine_Connection_Db2|Doctrine_Connection_Firebird|Doctrine_Connection_Common| + * Doctrine_Manager|Doctrine_Connection|Doctrine_Table */ public function setListener($listener) { diff --git a/lib/Doctrine/Connection/Profiler.php b/lib/Doctrine/Connection/Profiler.php index aafd772cf..7e147df1a 100644 --- a/lib/Doctrine/Connection/Profiler.php +++ b/lib/Doctrine/Connection/Profiler.php @@ -66,11 +66,11 @@ class Doctrine_Connection_Profiler implements Doctrine_Overloadable, IteratorAgg /** * method overloader * this method is used for invoking different listeners, for the full - * list of availible listeners, see Doctrine_Db_EventListener + * list of availible listeners, see Doctrine_EventListener * * @param string $m the name of the method * @param array $a method arguments - * @see Doctrine_Db_EventListener + * @see Doctrine_EventListener * @return boolean */ public function __call($m, $a) @@ -150,17 +150,17 @@ class Doctrine_Connection_Profiler implements Doctrine_Overloadable, IteratorAgg /** * pop the last event from the event stack * - * @return Doctrine_Db_Event + * @return Doctrine_Event */ public function pop() { return array_pop($this->events); } /** - * Get the Doctrine_Db_Event object for the last query that was run, regardless if it has + * Get the Doctrine_Event object for the last query that was run, regardless if it has * ended or not. If the event has not ended, it's end time will be Null. * - * @return Doctrine_Db_Event + * @return Doctrine_Event */ public function lastEvent() { diff --git a/lib/Doctrine/Connection/Statement.php b/lib/Doctrine/Connection/Statement.php index af6095c64..3a5f4618d 100644 --- a/lib/Doctrine/Connection/Statement.php +++ b/lib/Doctrine/Connection/Statement.php @@ -257,7 +257,7 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf $cursorOrientation = Doctrine::FETCH_ORI_NEXT, $cursorOffset = null) { - $event = new Doctrine_Db_Event($this, Doctrine_Event::STMT_FETCH, $this->_stmt->getQuery()); + $event = new Doctrine_Event($this, Doctrine_Event::STMT_FETCH, $this->_stmt->getQuery()); $event->fetchMode = $fetchMode; $event->cursorOrientation = $cursorOrientation; @@ -289,7 +289,7 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf public function fetchAll($fetchMode = Doctrine::FETCH_BOTH, $columnIndex = null) { - $event = new Doctrine_Db_Event($this, Doctrine_Event::STMT_FETCHALL, $this->_stmt->getQuery()); + $event = new Doctrine_Event($this, Doctrine_Event::STMT_FETCHALL, $this->_stmt->getQuery()); $event->fetchMode = $fetchMode; $event->columnIndex = $columnIndex; diff --git a/lib/Doctrine/Db.php b/lib/Doctrine/Db.php index 8da60d32f..36c120134 100644 --- a/lib/Doctrine/Db.php +++ b/lib/Doctrine/Db.php @@ -33,6 +33,6 @@ class Doctrine_Db { public function __construct() { - throw new Exception('Doctrine_Db has been deprecated. The functionality has been merged into Doctrine_Connection.'); + throw new Doctrine_Exception('Doctrine_Db has been deprecated. The functionality has been merged into Doctrine_Connection.'); } } diff --git a/lib/Doctrine/Event.php b/lib/Doctrine/Event.php index ad45f3da1..7418a8100 100644 --- a/lib/Doctrine/Event.php +++ b/lib/Doctrine/Event.php @@ -91,9 +91,10 @@ class Doctrine_Event /** * constructor * - * @param Doctrine_Db $invoker the handler which invoked this event - * @param integer $code the event code - * @param string $query the sql query associated with this event (if any) + * @param Doctrine_Connection|Doctrine_Connection_Statement| + Doctrine_Connection_UnitOfWork|Doctrine_Transaction $invoker the handler which invoked this event + * @param integer $code the event code + * @param string $query the sql query associated with this event (if any) */ public function __construct($invoker, $code, $query = null, $params = array()) { @@ -225,7 +226,8 @@ class Doctrine_Event * getInvoker * returns the handler that invoked this event * - * @return Doctrine_Db the handler that invoked this event + * @return Doctrine_Connection|Doctrine_Connection_Statement| + * Doctrine_Connection_UnitOfWork|Doctrine_Transaction the handler that invoked this event */ public function getInvoker() { diff --git a/lib/Doctrine/Hydrate.php b/lib/Doctrine/Hydrate.php index d82616fdf..30be228c7 100644 --- a/lib/Doctrine/Hydrate.php +++ b/lib/Doctrine/Hydrate.php @@ -653,7 +653,7 @@ class Doctrine_Hydrate extends Doctrine_Object implements Serializable if ($this->isLimitSubqueryUsed() && - $this->_conn->getDBH()->getAttribute(Doctrine::ATTR_DRIVER_NAME) !== 'mysql') { + $this->_conn->getAttribute(Doctrine::ATTR_DRIVER_NAME) !== 'mysql') { $params = array_merge($params, $params); } diff --git a/lib/Doctrine/Lib.php b/lib/Doctrine/Lib.php index f8d8b05b7..013725271 100644 --- a/lib/Doctrine/Lib.php +++ b/lib/Doctrine/Lib.php @@ -190,7 +190,7 @@ class Doctrine_Lib $r[] = 'State : ' . Doctrine_Lib::getConnectionStateAsString($connection->transaction->getState()); $r[] = 'Open Transactions : ' . $connection->transaction->getTransactionLevel(); $r[] = 'Table in memory : ' . $connection->count(); - $r[] = 'Driver name : ' . $connection->getDbh()->getAttribute(Doctrine::ATTR_DRIVER_NAME); + $r[] = 'Driver name : ' . $connection->getAttribute(Doctrine::ATTR_DRIVER_NAME); $r[] = ""; return implode("\n",$r)."
"; diff --git a/lib/Doctrine/Manager.php b/lib/Doctrine/Manager.php index f3802b8a2..f06aa91cd 100644 --- a/lib/Doctrine/Manager.php +++ b/lib/Doctrine/Manager.php @@ -211,10 +211,6 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera if ( ! ($adapter instanceof PDO) && ! in_array('Doctrine_Adapter_Interface', class_implements($adapter))) { throw new Doctrine_Manager_Exception("First argument should be an instance of PDO or implement Doctrine_Adapter_Interface"); } - - if ($adapter instanceof Doctrine_Db) { - $adapter->setName($name); - } $driverName = $adapter->getAttribute(Doctrine::ATTR_DRIVER_NAME); } elseif (is_array($adapter)) { diff --git a/lib/Doctrine/Query.php b/lib/Doctrine/Query.php index 9b3a2e710..d90d7913f 100644 --- a/lib/Doctrine/Query.php +++ b/lib/Doctrine/Query.php @@ -840,7 +840,7 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable // initialize the base of the subquery $subquery = 'SELECT DISTINCT ' . $primaryKey; - if ($this->_conn->getDBH()->getAttribute(PDO::ATTR_DRIVER_NAME) == 'pgsql') { + if ($this->_conn->getAttribute(Doctrine::ATTR_DRIVER_NAME) == 'pgsql') { // pgsql needs the order by fields to be preserved in select clause foreach ($this->parts['orderby'] as $part) { diff --git a/lib/Doctrine/Record.php b/lib/Doctrine/Record.php index 0b111e6cd..d7fcb5541 100644 --- a/lib/Doctrine/Record.php +++ b/lib/Doctrine/Record.php @@ -1548,8 +1548,8 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite /** * addListener * - * @param Doctrine_Db_EventListener_Interface|Doctrine_Overloadable $listener - * @return Doctrine_Db + * @param Doctrine_EventListener_Interface|Doctrine_Overloadable $listener + * @return Doctrine_Record */ public function addListener($listener, $name = null) { @@ -1559,7 +1559,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite /** * getListener * - * @return Doctrine_Db_EventListener_Interface|Doctrine_Overloadable + * @return Doctrine_EventListener_Interface|Doctrine_Overloadable */ public function getListener() { @@ -1568,8 +1568,8 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite /** * setListener * - * @param Doctrine_Db_EventListener_Interface|Doctrine_Overloadable $listener - * @return Doctrine_Db + * @param Doctrine_EventListener_Interface|Doctrine_Overloadable $listener + * @return Doctrine_Record */ public function setListener($listener) {