Author: romanb
Date: 2008-09-13 11:28:29 +0100 (Sat, 13 Sep 2008)
New Revision: 4962

Added:
   trunk/lib/Doctrine/DBAL/Statement.php
Modified:
   trunk/lib/Doctrine/DBAL/Connection.php
   trunk/lib/Doctrine/DBAL/Driver/PDOConnection.php
   trunk/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php
   trunk/lib/Doctrine/DBAL/DriverManager.php
   trunk/lib/Doctrine/ORM/EntityManager.php
   trunk/lib/Doctrine/ORM/Internal/CommitOrderCalculator.php
   trunk/lib/Doctrine/ORM/Internal/CommitOrderNode.php
   trunk/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php
   trunk/lib/Doctrine/ORM/Internal/Hydration/ArrayDriver.php
   trunk/lib/Doctrine/ORM/Internal/Hydration/ObjectDriver.php
   trunk/tests/lib/Doctrine_TestUtil.php
Log:
minor refactorings on code and API docs

Modified: trunk/lib/Doctrine/DBAL/Connection.php
===================================================================
--- trunk/lib/Doctrine/DBAL/Connection.php      2008-09-13 10:28:20 UTC (rev 
4961)
+++ trunk/lib/Doctrine/DBAL/Connection.php      2008-09-13 10:28:29 UTC (rev 
4962)
@@ -26,9 +26,9 @@
 #use Doctrine::DBAL::Exceptions::ConnectionException;
 
 /**
- * A wrapper around a Doctrine::DBAL::Connection that adds features like
- * events, transaction isolation levels, configuration, emulated transaction 
nesting
- * and more.
+ * A wrapper around a Doctrine::DBAL::Driver::Connection that adds features 
like
+ * events, transaction isolation levels, configuration, emulated transaction 
nesting,
+ * lazy connecting and more.
  *
  * @license     http://www.opensource.org/licenses/lgpl-license.php LGPL
  * @since       1.0
@@ -53,13 +53,24 @@
  * 
  * Doctrine::DBAL could ship with a simple standard broker that uses a 
primitive
  * round-robin approach to distribution. User can provide its own brokers.
- * @todo Rename to ConnectionWrapper
  */
 class Doctrine_DBAL_Connection
 {
+    /**
+     * Constant for transaction isolation level READ UNCOMMITTED.
+     */
     const TRANSACTION_READ_UNCOMMITTED = 1;
+    /**
+     * Constant for transaction isolation level READ COMMITTED.
+     */
     const TRANSACTION_READ_COMMITTED = 2;
+    /**
+     * Constant for transaction isolation level REPEATABLE READ.
+     */
     const TRANSACTION_REPEATABLE_READ = 3;
+    /**
+     * Constant for transaction isolation level SERIALIZABLE.
+     */
     const TRANSACTION_SERIALIZABLE = 4;
     
     /**
@@ -84,13 +95,6 @@
     protected $_eventManager;
     
     /**
-     * The name of this connection driver.
-     *
-     * @var string $driverName                  
-     */
-    protected $_driverName;
-    
-    /**
      * Whether or not a connection has been established.
      *
      * @var boolean               
@@ -98,18 +102,6 @@
     protected $_isConnected = false;
     
     /**
-     * Boolean flag that indicates whether identifiers should get quoted.
-     *
-     * @var boolean
-     */
-    protected $_quoteIdentifiers;
-    
-    /**
-     * @var array
-     */
-    protected $_serverInfo = array();
-    
-    /**
      * The transaction nesting level.
      *
      * @var integer
@@ -131,16 +123,6 @@
     protected $_params = array();
     
     /**
-     * List of all available drivers.
-     * 
-     * @var array $availableDrivers
-     * @todo Move elsewhere.       
-     */
-    private static $_availableDrivers = array(
-            'Mysql', 'Pgsql', 'Oracle', 'Informix', 'Mssql', 'Sqlite', 
'Firebird'
-            );
-    
-    /**
      * The query count. Represents the number of executed database queries by 
the connection.
      *
      * @var integer
@@ -154,13 +136,6 @@
      * @var Doctrine::DBAL::Platforms::DatabasePlatform
      */
     protected $_platform;
-
-    /**
-     * The transaction object.
-     *
-     * @var Doctrine::DBAL::Transaction
-     */
-    protected $_transaction;
     
     /**
      * The schema manager.
@@ -170,6 +145,13 @@
     protected $_schemaManager;
     
     /**
+     * The used DBAL driver.
+     *
+     * @var Doctrine::DBAL::Driver
+     */
+    protected $_driver;
+    
+    /**
      * Constructor.
      * Creates a new Connection.
      *
@@ -229,36 +211,6 @@
     }
     
     /**
-     * Returns an array of available PDO drivers
-     * @todo Move elsewhere.
-     */
-    public static function getAvailableDrivers()
-    {
-        return PDO::getAvailableDrivers();
-    }
-
-    /**
-     * Gets the name of the instance driver
-     *
-     * @return void
-     */
-    public function getDriverName()
-    {
-        return $this->_driverName;
-    }
-    
-    /**
-     * Gets the PDO handle used by the connection.
-     *
-     * @return PDO
-     */
-    public function getPdo()
-    {
-        $this->connect();
-        return $this->_conn;
-    }
-    
-    /**
      * Establishes the connection with the database.
      *
      * @return boolean
@@ -268,11 +220,6 @@
         if ($this->_isConnected) {
             return false;
         }
-
-        // TODO: the extension_loaded check can happen earlier, maybe in the 
factory
-        if ( ! extension_loaded('pdo')) {
-            throw new Doctrine_Connection_Exception("Couldn't locate driver 
named " . $e[0]);
-        }
         
         $driverOptions = isset($this->_params['driverOptions']) ?
                 $this->_params['driverOptions'] : array();
@@ -280,14 +227,13 @@
                 $this->_params['user'] : null;
         $password = isset($this->_params['password']) ?
                 $this->_params['password'] : null;
-        $this->_conn = new PDO(
-                $this->_constructPdoDsn(),
+        
+        $this->_conn = $this->_driver->connect(
+                $this->_params,
                 $user,
                 $password,
                 $driverOptions
                 );
-        $this->_conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
-        $this->_conn->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER);
 
         $this->_isConnected = true;
 
@@ -295,46 +241,14 @@
     }
     
     /**
-     * Establishes the connection with the database.
+     * Whether an actual connection to the database is established.
      *
      * @return boolean
      */
-    public function connect2()
+    public function isConnected()
     {
-        if ($this->_isConnected) {
-            return false;
-        }
-        
-        $driverOptions = isset($this->_params['driverOptions']) ?
-                $this->_params['driverOptions'] : array();
-        $user = isset($this->_params['user']) ?
-                $this->_params['user'] : null;
-        $password = isset($this->_params['password']) ?
-                $this->_params['password'] : null;
-                
-        $this->_conn = $this->_driver->connect($this->_params, $user, 
$password, $driverOptions);
-        
-        $this->_conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
-        $this->_conn->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER);
-
-        $this->_isConnected = true;
-
-        return true;
+        return $this->_isConnected;
     }
-    
-    /**
-     * Constructs the PDO DSN for use in the PDO constructor.
-     * Concrete connection implementations override this implementation to
-     * create the proper DSN.
-     * 
-     * @return string
-     * @todo make abstract, implement in subclasses.
-     * @todo throw different exception?
-     */
-    protected function _constructPdoDsn()
-    {
-        throw Doctrine_Exception::notImplemented('_constructPdoDsn', 
get_class($this));
-    }
 
     /**
      * Deletes table row(s) matching the specified identifier.
@@ -463,15 +377,10 @@
      *   + pgsql
      *   + sqlite
      *
-     * InterBase doesn't seem to be able to use delimited identifiers
-     * via PHP 4.  They work fine under PHP 5.
-     *
      * @param string $str           identifier name to be quoted
      * @param bool $checkOption     check the 'quote_identifier' option
      *
      * @return string               quoted identifier string
-     * @todo Moved to DatabasePlatform
-     * @deprecated
      */
     public function quoteIdentifier($str)
     {
@@ -479,7 +388,7 @@
     }
 
     /**
-     * Quotes given input parameter.
+     * Quotes a given input parameter.
      *
      * @param mixed $input  Parameter to be quoted.
      * @param string $type  Type of the parameter.
@@ -577,9 +486,10 @@
     }
     
     /**
-     * prepare
+     * Prepares an SQL statement.
      *
      * @param string $statement
+     * @return Doctrine::DBAL::Statement
      */
     public function prepare($statement)
     {
@@ -675,7 +585,6 @@
      * Returns the number of queries executed by the connection.
      *
      * @return integer
-     * @todo Better name: getQueryCount()
      */
     public function getQueryCount()
     {
@@ -701,26 +610,8 @@
      */
     public function setTransactionIsolation($level)
     {
-        $sql = "";
-        switch ($level) {
-            case Doctrine_DBAL_Connection::TRANSACTION_READ_UNCOMMITTED:
-                $sql = 
$this->_platform->getSetTransactionIsolationReadUncommittedSql();
-                break;
-            case Doctrine_DBAL_Connection::TRANSACTION_READ_COMMITTED:
-                $sql = 
$this->_platform->getSetTransactionIsolationReadCommittedSql();
-                break;
-            case Doctrine_DBAL_Connection::TRANSACTION_REPEATABLE_READ:
-                $sql = 
$this->_platform->getSetTransactionIsolationRepeatableReadSql();
-                break;
-            case Doctrine_DBAL_Connection::TRANSACTION_SERIALIZABLE:
-                $sql = 
$this->_platform->getSetTransactionIsolationSerializableSql();
-                break;
-            default:
-                throw new 
Doctrine_Common_Exceptions_DoctrineException('isolation level is not supported: 
' . $isolation);
-        }
         $this->_transactionIsolationLevel = $level;
-        
-        return $this->exec($sql);
+        return 
$this->exec($this->_platform->getSetTransactionIsolationSql($level));
     }
     
     /**
@@ -734,7 +625,7 @@
     }
 
     /**
-     * Returns the current total transaction nesting level.
+     * Returns the current transaction nesting level.
      *
      * @return integer  The nesting level. A value of 0 means theres no active 
transaction.
      */
@@ -785,10 +676,8 @@
      *
      * if trying to set a savepoint and there is no active transaction
      * a new transaction is being started.
-     *
-     * @param string $savepoint                 name of a savepoint to set
-     * @throws Doctrine_Transaction_Exception   if the transaction fails at 
database level
-     * @return integer                          current transaction nesting 
level
+     * 
+     * @return boolean
      */
     public function beginTransaction()
     {
@@ -804,10 +693,7 @@
      * progress or release a savepoint. This function may only be called when
      * auto-committing is disabled, otherwise it will fail.
      *
-     * @param string $savepoint                 name of a savepoint to release
-     * @throws Doctrine_Transaction_Exception   if the transaction fails at 
PDO level
-     * @throws Doctrine_Validator_Exception     if the transaction fails due 
to record validations
-     * @return boolean                          false if commit couldn't be 
performed, true otherwise
+     * @return boolean FALSE if commit couldn't be performed, TRUE otherwise
      */
     public function commit()
     {
@@ -972,7 +858,7 @@
     public function getSchemaManager()
     {
         if ( ! $this->_schemaManager) {
-            $this->_schemaManager = $this->_driver->getSchemaManager();
+            $this->_schemaManager = $this->_driver->getSchemaManager($this);
         }
         return $this->_schemaManager;
     }

Modified: trunk/lib/Doctrine/DBAL/Driver/PDOConnection.php
===================================================================
--- trunk/lib/Doctrine/DBAL/Driver/PDOConnection.php    2008-09-13 10:28:20 UTC 
(rev 4961)
+++ trunk/lib/Doctrine/DBAL/Driver/PDOConnection.php    2008-09-13 10:28:29 UTC 
(rev 4962)
@@ -1,11 +1,19 @@
 <?php
 
+/**
+ * PDO implementation of the driver Connection interface.
+ * Used by all PDO-based drivers.
+ *
+ * @since 2.0
+ */
 class Doctrine_DBAL_Driver_PDOConnection extends PDO implements 
Doctrine_DBAL_Driver_Connection
 {
     public function __construct($dsn, $user = null, $password = null, array 
$options = null)
     {
         parent::__construct($dsn, $user, $password, $options);
         $this->setAttribute(PDO::ATTR_STATEMENT_CLASS, 
array('Doctrine_DBAL_Driver_PDOStatement', array()));
+        $this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+        $this->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER);
     }
 }
 

Modified: trunk/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php
===================================================================
--- trunk/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php 2008-09-13 10:28:20 UTC 
(rev 4961)
+++ trunk/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php 2008-09-13 10:28:29 UTC 
(rev 4962)
@@ -4,9 +4,22 @@
 
 #use Doctrine::DBAL::Driver;
 
+/**
+ * The PDO Sqlite driver.
+ *
+ * @since 2.0
+ */
 class Doctrine_DBAL_Driver_PDOSqlite_Driver implements Doctrine_DBAL_Driver
 {
-    
+    /**
+     * Tries to establish a database connection to SQLite.
+     *
+     * @param array $params
+     * @param unknown_type $username
+     * @param unknown_type $password
+     * @param array $driverOptions
+     * @return unknown
+     */
     public function connect(array $params, $username = null, $password = null, 
array $driverOptions = array())
     {
         return new Doctrine_DBAL_Driver_PDOConnection(
@@ -34,11 +47,20 @@
         return $dsn;
     }
     
+    /**
+     * Gets the database platform that is relevant for this driver.
+     */
     public function getDatabasePlatform()
     {
         return new Doctrine_DBAL_Platforms_SqlitePlatform();
     }
     
+    /**
+     * Gets the schema manager that is relevant for this driver.
+     *
+     * @param Doctrine::DBAL::Connection $conn
+     * @return Doctrine::DBAL::Schema::AbstractSchemaManager
+     */
     public function getSchemaManager(Doctrine_DBAL_Connection $conn)
     {
         return new Doctrine_DBAL_Schema_SqliteSchemaManager($conn);

Modified: trunk/lib/Doctrine/DBAL/DriverManager.php
===================================================================
--- trunk/lib/Doctrine/DBAL/DriverManager.php   2008-09-13 10:28:20 UTC (rev 
4961)
+++ trunk/lib/Doctrine/DBAL/DriverManager.php   2008-09-13 10:28:29 UTC (rev 
4962)
@@ -22,19 +22,19 @@
 #namespace Doctrine::DBAL;
 
 /**
- * Factory for creating dbms-specific Connection instances.
+ * Factory for creating Doctrine::DBAL::Connection instances.
  *
  * @author Roman Borschel <[EMAIL PROTECTED]>
  * @since 2.0
  */
-class Doctrine_DBAL_DriverManager
+final class Doctrine_DBAL_DriverManager
 {
     /**
      * List of supported drivers and their mappings to the driver class.
      *
      * @var array
      */
-     private $_drivers = array(
+     private static $_driverMap = array(
             'pdo_mysql'  => 'Doctrine_DBAL_Driver_PDOMySql_Driver',
             'pdo_sqlite' => 'Doctrine_DBAL_Driver_PDOSqlite_Driver',
             'pdo_pgsql'  => 'Doctrine_DBAL_Driver_PDOPgSql_Driver',
@@ -44,18 +44,53 @@
             'pdo_informix' => 'Doctrine_DBAL_Driver_PDOInformix_Driver',
             );
     
-    public function __construct()
-    {
-        
-    }
-    
+    private function __construct() {}
+            
     /**
-     * Creates a connection object with the specified parameters.
+     * Creates a connection object based on the specified parameters.
+     * This method returns a Doctrine::DBAL::Connection which wraps the 
underlying
+     * driver connection.
      *
-     * @param array $params
-     * @return Connection
+     * $params must contain at least one of the following.
+     * 
+     * Either 'driver' with one of the following values:
+     *     pdo_mysql
+     *     pdo_sqlite
+     *     pdo_pgsql
+     *     pdo_oracle
+     *     pdo_mssql
+     *     pdo_firebird
+     *     pdo_informix
+     * 
+     * OR 'driverClass' that contains the full class name (with namespace) of 
the
+     * driver class to instantiate.
+     * 
+     * Other (optional) parameters:
+     * 
+     * <b>user (string)</b>:
+     * The username to use when connecting. 
+     * 
+     * <b>password (string)</b>:
+     * The password to use when connecting.
+     * 
+     * <b>driverOptions (array)</b>:
+     * Any additional driver-specific options for the driver. These are just 
passed
+     * through to the driver.
+     * 
+     * <b>pdo</b>:
+     * You can pass an existing PDO instance through this parameter. The PDO
+     * instance will be wrapped in a Doctrine::DBAL::Connection.
+     * 
+     * <b>wrapperClass</b>:
+     * You may specify a custom wrapper class through the 'wrapperClass'
+     * parameter but this class MUST inherit from Doctrine::DBAL::Connection.
+     * 
+     * @param array $params The parameters.
+     * @param Doctrine::Common::Configuration The configuration to use.
+     * @param Doctrine::Common::EventManager The event manager to use.
+     * @return Doctrine::DBAL::Connection
      */
-    public function getConnection(array $params, Doctrine_Common_Configuration 
$config = null,
+    public static function getConnection(array $params, 
Doctrine_Common_Configuration $config = null,
             Doctrine_Common_EventManager $eventManager = null)
     {
         // create default config and event manager, if not set
@@ -72,18 +107,18 @@
         } else if (isset($params['pdo'])) {
             $params['driver'] = 
$params['pdo']->getAttribute(PDO::ATTR_DRIVER_NAME);
         } else {
-            $this->_checkParams($params);
+            self::_checkParams($params);
         }
         if (isset($params['driverClass'])) {
             $className = $params['driverClass'];
         } else {
-            $className = $this->_drivers[$params['driver']];
+            $className = self::$_driverMap[$params['driver']];
         }
         
         $driver = new $className();
         
         $wrapperClass = 'Doctrine_DBAL_Connection';
-        if (isset($params['wrapperClass'])) {
+        if (isset($params['wrapperClass']) && 
is_subclass_of($params['wrapperClass'], $wrapperClass)) {
             $wrapperClass = $params['wrapperClass'];
         }
         
@@ -95,7 +130,7 @@
      *
      * @param array $params
      */
-    private function _checkParams(array $params)
+    private static function _checkParams(array $params)
     {        
         // check existance of mandatory parameters
         
@@ -107,7 +142,7 @@
         // check validity of parameters
         
         // driver
-        if ( isset($params['driver']) && ! 
isset($this->_drivers[$params['driver']])) {
+        if ( isset($params['driver']) && ! 
isset(self::$_driverMap[$params['driver']])) {
             throw 
Doctrine_DBAL_Exceptions_DBALException::unknownDriver($params['driver']);
         }
     }

Added: trunk/lib/Doctrine/DBAL/Statement.php
===================================================================
--- trunk/lib/Doctrine/DBAL/Statement.php                               (rev 0)
+++ trunk/lib/Doctrine/DBAL/Statement.php       2008-09-13 10:28:29 UTC (rev 
4962)
@@ -0,0 +1,438 @@
+<?php
+/*
+ *  $Id: Statement.php 1532 2007-05-31 17:45:07Z zYne $
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the LGPL. For more information, see
+ * <http://www.phpdoctrine.org>.
+ */
+
+#namespace Doctrine::DBAL;
+
+/**
+ * A thin wrapper around PDOStatement.
+ *
+ * @author      Konsta Vesterinen <[EMAIL PROTECTED]>
+ * @license     http://www.opensource.org/licenses/lgpl-license.php LGPL
+ * @link        www.phpdoctrine.org
+ * @since       1.0
+ * @version     $Revision: 1532 $
+ * @todo Do we seriously need this wrapper?
+ */
+class Doctrine_DBAL_Statement
+{
+    /**
+     * @var Doctrine_Connection $conn       Doctrine_Connection object, every 
connection
+     *                                      statement holds an instance of 
Doctrine_Connection
+     */
+    protected $_conn;
+
+    /**
+     * @var Doctrine::DBAL::Driver::Statement
+     */
+    protected $_stmt;
+
+    /**
+     * constructor
+     *
+     * @param Doctrine_Connection $conn     Doctrine_Connection object, every 
connection
+     *                                      statement holds an instance of 
Doctrine_Connection
+     * @param mixed $stmt
+     */
+    public function __construct(Doctrine_Connection $conn, $stmt)
+    {
+        $this->_conn = $conn;
+        $this->_stmt = $stmt;
+
+        if ($stmt === false) {
+            throw new Doctrine_Exception('Unknown statement object given.');
+        }
+    }
+
+    /**
+     * getConnection
+     * returns the connection object this statement uses
+     *
+     * @return Doctrine_Connection
+     */
+    public function getConnection()
+    {
+        return $this->_conn;
+    }
+    public function getStatement()
+    {
+        return $this->_stmt;
+    }
+    public function getQuery()
+    {
+        return $this->_stmt->queryString;
+    }
+
+    /**
+     * Bind a column to a PHP variable
+     *
+     * @param mixed $column         Number of the column (1-indexed) or name 
of the column in the result set.
+     *                              If using the column name, be aware that 
the name should match
+     *                              the case of the column, as returned by the 
driver.
+     *
+     * @param string $param         Name of the PHP variable to which the 
column will be bound.
+     * @param integer $type         Data type of the parameter, specified by 
the Doctrine::PARAM_* constants.
+     * @return boolean              Returns TRUE on success or FALSE on failure
+     */
+    public function bindColumn($column, $param, $type = null)
+    {
+        if ($type === null) {
+            return $this->_stmt->bindColumn($column, $param);
+        } else {
+            return $this->_stmt->bindColumn($column, $param, $type);
+        }
+    }
+
+    /**
+     * bindValue
+     * Binds a value to a corresponding named or question mark
+     * placeholder in the SQL statement that was use to prepare the statement.
+     *
+     * @param mixed $param          Parameter identifier. For a prepared 
statement using named placeholders,
+     *                              this will be a parameter name of the form 
:name. For a prepared statement
+     *                              using question mark placeholders, this 
will be the 1-indexed position of the parameter
+     *
+     * @param mixed $value          The value to bind to the parameter.
+     * @param integer $type         Explicit data type for the parameter using 
the Doctrine::PARAM_* constants.
+     *
+     * @return boolean              Returns TRUE on success or FALSE on 
failure.
+     */
+    public function bindValue($param, $value, $type = null)
+    {
+        if ($type === null) {
+            return $this->_stmt->bindValue($param, $value);
+        } else {
+            return $this->_stmt->bindValue($param, $value, $type);
+        }
+    }
+
+    /**
+     * Binds a PHP variable to a corresponding named or question mark 
placeholder in the
+     * SQL statement that was use to prepare the statement. Unlike 
Doctrine_Adapter_Statement_Interface->bindValue(),
+     * the variable is bound as a reference and will only be evaluated at the 
time
+     * that Doctrine_Adapter_Statement_Interface->execute() is called.
+     *
+     * Most parameters are input parameters, that is, parameters that are
+     * used in a read-only fashion to build up the query. Some drivers support 
the invocation
+     * of stored procedures that return data as output parameters, and some 
also as input/output
+     * parameters that both send in data and are updated to receive it.
+     *
+     * @param mixed $param          Parameter identifier. For a prepared 
statement using named placeholders,
+     *                              this will be a parameter name of the form 
:name. For a prepared statement
+     *                              using question mark placeholders, this 
will be the 1-indexed position of the parameter
+     *
+     * @param mixed $variable       Name of the PHP variable to bind to the 
SQL statement parameter.
+     *
+     * @param integer $type         Explicit data type for the parameter using 
the Doctrine::PARAM_* constants. To return
+     *                              an INOUT parameter from a stored 
procedure, use the bitwise OR operator to set the
+     *                              Doctrine::PARAM_INPUT_OUTPUT bits for the 
data_type parameter.
+     *
+     * @param integer $length       Length of the data type. To indicate that 
a parameter is an OUT parameter
+     *                              from a stored procedure, you must 
explicitly set the length.
+     * @param mixed $driverOptions
+     * @return boolean              Returns TRUE on success or FALSE on 
failure.
+     */
+    public function bindParam($column, &$variable, $type = null, $length = 
null, $driverOptions = array())
+    {
+        if ($type === null) {
+            return $this->_stmt->bindParam($column, $variable);
+        } else {
+            return $this->_stmt->bindParam($column, $variable, $type, $length, 
$driverOptions);
+        }
+    }
+
+    /**
+     * Closes the cursor, enabling the statement to be executed again.
+     *
+     * @return boolean              Returns TRUE on success or FALSE on 
failure.
+     */
+    public function closeCursor()
+    {
+        return $this->_stmt->closeCursor();
+    }
+
+    /**
+     * Returns the number of columns in the result set
+     *
+     * @return integer              Returns the number of columns in the 
result set represented
+     *                              by the 
Doctrine_Adapter_Statement_Interface object. If there is no result set,
+     *                              this method should return 0.
+     */
+    public function columnCount()
+    {
+        return $this->_stmt->columnCount();
+    }
+
+    /**
+     * Fetch the SQLSTATE associated with the last operation on the statement 
handle
+     *
+     * @see Doctrine_Adapter_Interface::errorCode()
+     * @return string       error code string
+     */
+    public function errorCode()
+    {
+        return $this->_stmt->errorCode();
+    }
+
+    /**
+     * Fetch extended error information associated with the last operation on 
the statement handle
+     *
+     * @see Doctrine_Adapter_Interface::errorInfo()
+     * @return array        error info array
+     */
+    public function errorInfo()
+    {
+        return $this->_stmt->errorInfo();
+    }
+
+    /**
+     * Executes a prepared statement
+     *
+     * If the prepared statement included parameter markers, you must either:
+     * call PDOStatement->bindParam() to bind PHP variables to the parameter 
markers:
+     * bound variables pass their value as input and receive the output value,
+     * if any, of their associated parameter markers or pass an array of 
input-only
+     * parameter values
+     *
+     *
+     * @param array $params             An array of values with as many 
elements as there are
+     *                                  bound parameters in the SQL statement 
being executed.
+     * @return boolean                  Returns TRUE on success or FALSE on 
failure.
+     */
+    public function execute($params = null)
+    {
+        try {
+            //$event = new Doctrine_Event($this, Doctrine_Event::STMT_EXECUTE, 
$this->getQuery(), $params);
+            //$this->_conn->getListener()->preStmtExecute($event);
+
+            $result = true;
+            //if ( ! $event->skipOperation) {
+                $result = $this->_stmt->execute($params);
+                //$this->_conn->incrementQueryCount();
+            //}
+
+            //$this->_conn->getListener()->postStmtExecute($event);
+
+            return $result;
+        } catch (PDOException $e) {
+            $this->_conn->rethrowException($e, $this);
+        }
+
+        return false;
+    }
+
+    /**
+     * fetch
+     *
+     * @see Doctrine::FETCH_* constants
+     * @param integer $fetchStyle           Controls how the next row will be 
returned to the caller.
+     *                                      This value must be one of the 
Doctrine::FETCH_* constants,
+     *                                      defaulting to Doctrine::FETCH_BOTH
+     *
+     * @param integer $cursorOrientation    For a PDOStatement object 
representing a scrollable cursor,
+     *                                      this value determines which row 
will be returned to the caller.
+     *                                      This value must be one of the 
Doctrine::FETCH_ORI_* constants, defaulting to
+     *                                      Doctrine::FETCH_ORI_NEXT. To 
request a scrollable cursor for your
+     *                                      
Doctrine_Adapter_Statement_Interface object,
+     *                                      you must set the 
Doctrine::ATTR_CURSOR attribute to Doctrine::CURSOR_SCROLL when you
+     *                                      prepare the SQL statement with 
Doctrine_Adapter_Interface->prepare().
+     *
+     * @param integer $cursorOffset         For a 
Doctrine_Adapter_Statement_Interface object representing a scrollable cursor 
for which the
+     *                                      $cursorOrientation parameter is 
set to Doctrine::FETCH_ORI_ABS, this value specifies
+     *                                      the absolute number of the row in 
the result set that shall be fetched.
+     *
+     *                                      For a 
Doctrine_Adapter_Statement_Interface object representing a scrollable cursor for
+     *                                      which the $cursorOrientation 
parameter is set to Doctrine::FETCH_ORI_REL, this value
+     *                                      specifies the row to fetch 
relative to the cursor position before
+     *                                      
Doctrine_Adapter_Statement_Interface->fetch() was called.
+     *
+     * @return mixed
+     */
+    public function fetch($fetchMode = Doctrine::FETCH_BOTH,
+                          $cursorOrientation = Doctrine::FETCH_ORI_NEXT,
+                          $cursorOffset = null)
+    {
+        //$event = new Doctrine_Event($this, Doctrine_Event::STMT_FETCH, 
$this->getQuery());
+        //$event->fetchMode = $fetchMode;
+        //$event->cursorOrientation = $cursorOrientation;
+        //$event->cursorOffset = $cursorOffset;
+
+        //$data = $this->_conn->getListener()->preFetch($event);
+
+        //if ( ! $event->skipOperation) {
+            $data = $this->_stmt->fetch($fetchMode, $cursorOrientation, 
$cursorOffset);
+        //}
+
+        //$this->_conn->getListener()->postFetch($event);
+
+        return $data;
+    }
+
+    /**
+     * Returns an array containing all of the result set rows
+     *
+     * @param integer $fetchMode            Controls how the next row will be 
returned to the caller.
+     *                                      This value must be one of the 
Doctrine::FETCH_* constants,
+     *                                      defaulting to Doctrine::FETCH_BOTH
+     *
+     * @param integer $columnIndex          Returns the indicated 0-indexed 
column when the value of $fetchStyle is
+     *                                      Doctrine::FETCH_COLUMN. Defaults 
to 0.
+     *
+     * @return array
+     */
+    public function fetchAll($fetchMode = Doctrine::FETCH_BOTH, $columnIndex = 
null)
+    {
+        //$event = new Doctrine_Event($this, Doctrine_Event::STMT_FETCHALL, 
$this->getQuery());
+        //$event->fetchMode = $fetchMode;
+        //$event->columnIndex = $columnIndex;
+        //$this->_conn->getListener()->preFetchAll($event);
+
+        //if ( ! $event->skipOperation) {
+            if ($columnIndex !== null) {
+                $data = $this->_stmt->fetchAll($fetchMode, $columnIndex);
+            } else {
+                $data = $this->_stmt->fetchAll($fetchMode);
+            }
+            //$event->data = $data;
+        //}
+
+        //$this->_conn->getListener()->postFetchAll($event);
+
+        return $data;
+    }
+
+    /**
+     * Returns a single column from the next row of a
+     * result set or FALSE if there are no more rows.
+     *
+     * @param integer $columnIndex          0-indexed number of the column you 
wish to retrieve from the row. If no
+     *                                      value is supplied, 
Doctrine_Adapter_Statement_Interface->fetchColumn()
+     *                                      fetches the first column.
+     *
+     * @return string                       returns a single column in the 
next row of a result set.
+     */
+    public function fetchColumn($columnIndex = 0)
+    {
+        return $this->_stmt->fetchColumn($columnIndex);
+    }
+
+    /**
+     * Fetches the next row and returns it as an object.
+     *
+     * Fetches the next row and returns it as an object. This function is an 
alternative to
+     * Doctrine_Adapter_Statement_Interface->fetch() with 
Doctrine::FETCH_CLASS or Doctrine::FETCH_OBJ style.
+     *
+     * @param string $className             Name of the created class, 
defaults to stdClass.
+     * @param array $args                   Elements of this array are passed 
to the constructor.
+     *
+     * @return mixed                        an instance of the required class 
with property names that correspond
+     *                                      to the column names or FALSE in 
case of an error.
+     */
+    public function fetchObject($className = 'stdClass', $args = array())
+    {
+        return $this->_stmt->fetchObject($className, $args);
+    }
+
+    /**
+     * Retrieve a statement attribute
+     *
+     * @param integer $attribute
+     * @see Doctrine::ATTR_* constants
+     * @return mixed                        the attribute value
+     */
+    public function getAttribute($attribute)
+    {
+        return $this->_stmt->getAttribute($attribute);
+    }
+
+    /**
+     * Returns metadata for a column in a result set
+     *
+     * @param integer $column               The 0-indexed column in the result 
set.
+     *
+     * @return array                        Associative meta data array with 
the following structure:
+     *
+     *          native_type                 The PHP native type used to 
represent the column value.
+     *          driver:decl_                type The SQL type used to 
represent the column value in the database. If the column in the result set is 
the result of a function, this value is not returned by 
PDOStatement->getColumnMeta().
+     *          flags                       Any flags set for this column.
+     *          name                        The name of this column as 
returned by the database.
+     *          len                         The length of this column. 
Normally -1 for types other than floating point decimals.
+     *          precision                   The numeric precision of this 
column. Normally 0 for types other than floating point decimals.
+     *          pdo_type                    The type of this column as 
represented by the PDO::PARAM_* constants.
+     */
+    public function getColumnMeta($column)
+    {
+        return $this->_stmt->getColumnMeta($column);
+    }
+
+    /**
+     * Advances to the next rowset in a multi-rowset statement handle
+     *
+     * Some database servers support stored procedures that return more than 
one rowset
+     * (also known as a result set). The nextRowset() method enables you to 
access the second
+     * and subsequent rowsets associated with a PDOStatement object. Each 
rowset can have a
+     * different set of columns from the preceding rowset.
+     *
+     * @return boolean                      Returns TRUE on success or FALSE 
on failure.
+     */
+    public function nextRowset()
+    {
+        return $this->_stmt->nextRowset();
+    }
+
+    /**
+     * rowCount() returns the number of rows affected by the last DELETE, 
INSERT, or UPDATE statement
+     * executed by the corresponding object.
+     *
+     * If the last SQL statement executed by the associated Statement object 
was a SELECT statement,
+     * some databases may return the number of rows returned by that 
statement. However,
+     * this behaviour is not guaranteed for all databases and should not be
+     * relied on for portable applications.
+     *
+     * @return integer                      Returns the number of rows.
+     */
+    public function rowCount()
+    {
+        return $this->_stmt->rowCount();
+    }
+
+    /**
+     * Set a statement attribute
+     *
+     * @param integer $attribute
+     * @param mixed $value                  the value of given attribute
+     * @return boolean                      Returns TRUE on success or FALSE 
on failure.
+     */
+    public function setAttribute($attribute, $value)
+    {
+        return $this->_stmt->setAttribute($attribute, $value);
+    }
+
+    /**
+     * Set the default fetch mode for this statement
+     *
+     * @param integer $mode                 The fetch mode must be one of the 
Doctrine::FETCH_* constants.
+     * @return boolean                      Returns 1 on success or FALSE on 
failure.
+     */
+    public function setFetchMode($mode, $arg1 = null, $arg2 = null)
+    {
+        return $this->_stmt->setFetchMode($mode, $arg1, $arg2);
+    }
+}

Modified: trunk/lib/Doctrine/ORM/EntityManager.php
===================================================================
--- trunk/lib/Doctrine/ORM/EntityManager.php    2008-09-13 10:28:20 UTC (rev 
4961)
+++ trunk/lib/Doctrine/ORM/EntityManager.php    2008-09-13 10:28:29 UTC (rev 
4962)
@@ -23,8 +23,7 @@
 
 #use Doctrine::Common::Configuration;
 #use Doctrine::Common::EventManager;
-#use Doctrine::Common::NullObject;
-#use Doctrine::DBAL::Connections::Connection;
+#use Doctrine::DBAL::Connection;
 #use Doctrine::ORM::Exceptions::EntityManagerException;
 #use Doctrine::ORM::Internal::UnitOfWork;
 #use Doctrine::ORM::Mapping::ClassMetadata;
@@ -355,6 +354,12 @@
         $this->_flushMode = $flushMode;
     }
     
+    /**
+     * Checks whether the given value is a valid flush mode.
+     *
+     * @param string $value
+     * @return boolean
+     */
     private function _isFlushMode($value)
     {
         return $value == self::FLUSHMODE_AUTO ||
@@ -398,34 +403,6 @@
     }
     
     /**
-     * Gets the result cache driver used by the EntityManager.
-     *
-     * @return Doctrine::ORM::Cache::CacheDriver The cache driver.
-     */
-    public function getResultCacheDriver()
-    {
-        if ( ! $this->getAttribute(Doctrine::ATTR_RESULT_CACHE)) {
-            throw new Doctrine_Exception('Result Cache driver not 
initialized.');
-        }
-        
-        return $this->getAttribute(Doctrine::ATTR_RESULT_CACHE);
-    }
-
-    /**
-     * getQueryCacheDriver
-     *
-     * @return Doctrine_Cache_Interface
-     */
-    public function getQueryCacheDriver()
-    {
-        if ( ! $this->getAttribute(Doctrine::ATTR_QUERY_CACHE)) {
-            throw new Doctrine_Exception('Query Cache driver not 
initialized.');
-        }
-        
-        return $this->getAttribute(Doctrine::ATTR_QUERY_CACHE);
-    }
-    
-    /**
      * Saves the given entity, persisting it's state.
      * 
      * @param Doctrine::ORM::Entity $entity
@@ -649,6 +626,9 @@
         return $this->_config;
     }
     
+    /**
+     * Throws an exception if the EntityManager is closed or currently not 
active.
+     */
     private function _errorIfNotActiveOrClosed()
     {
         if ( ! $this->isActive() || $this->_closed) {
@@ -702,9 +682,8 @@
             Doctrine_Common_EventManager $eventManager = null)
     {
         if (is_array($conn)) {
-            $connFactory = new Doctrine_DBAL_DriverManager();
-            $conn = $connFactory->getConnection($conn, $config, $eventManager);
-        } else if ( ! $conn instanceof Doctrine_Connection) {
+            $conn = Doctrine_DBAL_DriverManager::getConnection($conn, $config, 
$eventManager);
+        } else if ( ! $conn instanceof Doctrine_DBAL_Connection) {
             throw new Doctrine_Exception("Invalid parameter '$conn'.");
         }
         
@@ -722,7 +701,9 @@
     }
     
     /**
-     * Gets the currently active EntityManager.
+     * Static lookup to get the currently active EntityManager.
+     * This is used in the Entity constructor as well as unserialize() to 
connect
+     * the Entity with an EntityManager.
      *
      * @return Doctrine::ORM::EntityManager
      */

Modified: trunk/lib/Doctrine/ORM/Internal/CommitOrderCalculator.php
===================================================================
--- trunk/lib/Doctrine/ORM/Internal/CommitOrderCalculator.php   2008-09-13 
10:28:20 UTC (rev 4961)
+++ trunk/lib/Doctrine/ORM/Internal/CommitOrderCalculator.php   2008-09-13 
10:28:29 UTC (rev 4962)
@@ -26,7 +26,6 @@
  * correct order in which changes to entities need to be persisted.
  *
  * @since 2.0
- * @todo Rename to: CommitOrderCalculator
  * @author Roman Borschel <[EMAIL PROTECTED]> 
  */
 class Doctrine_ORM_Internal_CommitOrderCalculator
@@ -88,16 +87,34 @@
         return $this->_sorted;
     }
     
+    /**
+     * Adds a node to consider when ordering.
+     *
+     * @param mixed $key Somme arbitrary key for the node (must be unique!).
+     * @param unknown_type $node
+     */
     public function addNode($key, $node)
     {
         $this->_nodes[$key] = $node;
     }
     
+    /**
+     * Enter description here...
+     *
+     * @param unknown_type $key
+     * @param unknown_type $item
+     */
     public function addNodeWithItem($key, $item)
     {
         $this->_nodes[$key] = new Doctrine_ORM_Internal_CommitOrderNode($item, 
$this);
     }
     
+    /**
+     * Enter description here...
+     *
+     * @param unknown_type $key
+     * @return unknown
+     */
     public function getNodeForKey($key)
     {
         return $this->_nodes[$key];
@@ -108,13 +125,17 @@
         return isset($this->_nodes[$key]);
     }
     
+    /**
+     * Clears the current graph and the last result.
+     *
+     * @return void
+     */
     public function clear()
     {
         $this->_nodes = array();
         $this->_sorted = array();
     }
     
-    
     public function getNextTime()
     {
         return ++$this->_currentTime;

Modified: trunk/lib/Doctrine/ORM/Internal/CommitOrderNode.php
===================================================================
--- trunk/lib/Doctrine/ORM/Internal/CommitOrderNode.php 2008-09-13 10:28:20 UTC 
(rev 4961)
+++ trunk/lib/Doctrine/ORM/Internal/CommitOrderNode.php 2008-09-13 10:28:29 UTC 
(rev 4962)
@@ -22,7 +22,7 @@
 #namespace Doctrine::ORM::Internal;
 
 /**
- * A CommitOrderNode is a temporary wrapper around ClassMetadata objects
+ * A CommitOrderNode is a temporary wrapper around ClassMetadata instances
  * that is used to sort the order of commits.
  * 
  * @since 2.0
@@ -40,19 +40,32 @@
     private $_calculator;
     private $_relatedNodes = array();
     
+    /* The "time" when this node was first discovered during traversal */
     private $_discoveryTime;
+    /* The "time" when this node was finished during traversal */
     private $_finishingTime;
     
+    /* The wrapped object */
     private $_wrappedObj;
-    private $_relationEdges = array();
     
-    
+    /**
+     * Constructor.
+     * Creates a new node.
+     *
+     * @param mixed $wrappedObj The object to wrap.
+     * @param Doctrine::ORM::Internal::CommitOrderCalculator $calc The 
calculator.
+     */
     public function __construct($wrappedObj, 
Doctrine_ORM_Internal_CommitOrderCalculator $calc)
     {
         $this->_wrappedObj = $wrappedObj;
         $this->_calculator = $calc;
     }
     
+    /**
+     * Gets the wrapped object.
+     *
+     * @return mixed
+     */
     public function getClass()
     {
         return $this->_wrappedObj;
@@ -142,7 +155,7 @@
     /**
      * Adds a directed dependency (an edge on the graph). "$this -before-> 
$other".
      *
-     * @param Doctrine_Internal_CommitOrderNode $node
+     * @param Doctrine::ORM::Internal::CommitOrderNode $node
      */
     public function before(Doctrine_ORM_Internal_CommitOrderNode $node)
     {

Modified: trunk/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php
===================================================================
--- trunk/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php      
2008-09-13 10:28:20 UTC (rev 4961)
+++ trunk/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php      
2008-09-13 10:28:29 UTC (rev 4962)
@@ -62,9 +62,9 @@
 
 
     /**
-     * constructor
+     * Constructor.
      *
-     * @param Doctrine_Connection|null $connection
+     * @param Doctrine::ORM::EntityManager $em The EntityManager to use during 
hydration.
      */
     public function __construct(Doctrine_ORM_EntityManager $em)
     {
@@ -134,20 +134,14 @@
     }
 
     /**
-     * hydrateResultSet
-     *
      * Processes data returned by statement object.
      *
-     * This is method defines the core of Doctrine object population algorithm
-     * hence this method strives to be as fast as possible.
+     * This is method defines the core of Doctrine object/array population 
algorithm.
      *
-     * The key idea is the loop over the rowset only once doing all the needed 
operations
-     * within this massive loop.
-     *
      * @param mixed $stmt PDOStatement
      * @param integer $hydrationMode Doctrine processing mode to be used 
during hydration process.
      *                               One of the Doctrine::HYDRATE_* constants.
-     * @return mixed Doctrine_Collection|array
+     * @return mixed
      */
     abstract public function hydrateResultSet($parserResult);
 }

Modified: trunk/lib/Doctrine/ORM/Internal/Hydration/ArrayDriver.php
===================================================================
--- trunk/lib/Doctrine/ORM/Internal/Hydration/ArrayDriver.php   2008-09-13 
10:28:20 UTC (rev 4961)
+++ trunk/lib/Doctrine/ORM/Internal/Hydration/ArrayDriver.php   2008-09-13 
10:28:29 UTC (rev 4962)
@@ -126,7 +126,6 @@
     public function getLastKey(&$data)
     {
         end($data);
-        
         return key($data);
     }
     

Modified: trunk/lib/Doctrine/ORM/Internal/Hydration/ObjectDriver.php
===================================================================
--- trunk/lib/Doctrine/ORM/Internal/Hydration/ObjectDriver.php  2008-09-13 
10:28:20 UTC (rev 4961)
+++ trunk/lib/Doctrine/ORM/Internal/Hydration/ObjectDriver.php  2008-09-13 
10:28:29 UTC (rev 4962)
@@ -19,6 +19,8 @@
  * <http://www.phpdoctrine.org>.
  */
 
+#namespace Doctrine::ORM::Internal::Hydration;
+
 /**
  * Hydration strategy used for creating graphs of entities.
  *
@@ -28,7 +30,6 @@
  * @version     $Revision$
  * @author      Konsta Vesterinen <[EMAIL PROTECTED]>
  * @author      Roman Borschel <[EMAIL PROTECTED]>
- * @todo Rename to ObjectDriver
  */
 class Doctrine_ORM_Internal_Hydration_ObjectDriver
 {

Modified: trunk/tests/lib/Doctrine_TestUtil.php
===================================================================
--- trunk/tests/lib/Doctrine_TestUtil.php       2008-09-13 10:28:20 UTC (rev 
4961)
+++ trunk/tests/lib/Doctrine_TestUtil.php       2008-09-13 10:28:29 UTC (rev 
4962)
@@ -4,8 +4,6 @@
 {    
     public static function getConnection()
     {
-        $connFactory = new Doctrine_DBAL_DriverManager();
-        
         if (isset($GLOBALS['db_type'], $GLOBALS['db_username'], 
$GLOBALS['db_password'],
                 $GLOBALS['db_host'], $GLOBALS['db_name'])) {
             $params = array(
@@ -24,7 +22,7 @@
             );
         }
         
-        return $connFactory->getConnection($params);
+        return Doctrine_DBAL_DriverManager::getConnection($params);
     }
     /*
     public static function autoloadModel($className)


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"doctrine-svn" group.
 To post to this group, send email to [email protected]
 To unsubscribe from this group, send email to [EMAIL PROTECTED]
 For more options, visit this group at 
http://groups.google.co.uk/group/doctrine-svn?hl=en-GB
-~----------~----~----~----~------~----~------~--~---

Reply via email to