diff --git a/lib/Doctrine/Adapter.php b/lib/Doctrine/Adapter.php deleted file mode 100644 index cfa97a4eb..000000000 --- a/lib/Doctrine/Adapter.php +++ /dev/null @@ -1,106 +0,0 @@ -. - */ - -/** - * - * Doctrine_Adapter - * - * @package Doctrine - * @subpackage Adapter - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.phpdoctrine.org - * @since 1.0 - * @version $Revision$ - * @author Konsta Vesterinen - * @todo Remove. - */ -class Doctrine_Adapter -{ - const ATTR_AUTOCOMMIT = 0; - const ATTR_CASE = 8; - const ATTR_CLIENT_VERSION = 5; - const ATTR_CONNECTION_STATUS = 7; - const ATTR_CURSOR = 10; - const ATTR_CURSOR_NAME = 9; - const ATTR_DRIVER_NAME = 16; - const ATTR_ERRMODE = 3; - const ATTR_FETCH_CATALOG_NAMES = 15; - const ATTR_FETCH_TABLE_NAMES = 14; - const ATTR_MAX_COLUMN_LEN = 18; - const ATTR_ORACLE_NULLS = 11; - const ATTR_PERSISTENT = 12; - const ATTR_PREFETCH = 1; - const ATTR_SERVER_INFO = 6; - const ATTR_SERVER_VERSION = 4; - const ATTR_STATEMENT_CLASS = 13; - const ATTR_STRINGIFY_FETCHES = 17; - const ATTR_TIMEOUT = 2; - const CASE_LOWER = 2; - const CASE_NATURAL = 0; - const CASE_UPPER = 1; - const CURSOR_FWDONLY = 0; - const CURSOR_SCROLL = 1; - const ERR_ALREADY_EXISTS = NULL; - const ERR_CANT_MAP = NULL; - const ERR_CONSTRAINT = NULL; - const ERR_DISCONNECTED = NULL; - const ERR_MISMATCH = NULL; - const ERR_NO_PERM = NULL; - const ERR_NONE = '00000'; - const ERR_NOT_FOUND = NULL; - const ERR_NOT_IMPLEMENTED = NULL; - const ERR_SYNTAX = NULL; - const ERR_TRUNCATED = NULL; - const ERRMODE_EXCEPTION = 2; - const ERRMODE_SILENT = 0; - const ERRMODE_WARNING = 1; - const FETCH_ASSOC = 2; - const FETCH_BOTH = 4; - const FETCH_BOUND = 6; - const FETCH_CLASS = 8; - const FETCH_CLASSTYPE = 262144; - const FETCH_COLUMN = 7; - const FETCH_FUNC = 10; - const FETCH_GROUP = 65536; - const FETCH_INTO = 9; - const FETCH_LAZY = 1; - const FETCH_NAMED = 11; - const FETCH_NUM = 3; - const FETCH_OBJ = 5; - const FETCH_ORI_ABS = 4; - const FETCH_ORI_FIRST = 2; - const FETCH_ORI_LAST = 3; - const FETCH_ORI_NEXT = 0; - const FETCH_ORI_PRIOR = 1; - const FETCH_ORI_REL = 5; - const FETCH_SERIALIZE = 524288; - const FETCH_UNIQUE = 196608; - const NULL_EMPTY_STRING = 1; - const NULL_NATURAL = 0; - const NULL_TO_STRING = NULL; - const PARAM_BOOL = 5; - const PARAM_INPUT_OUTPUT = -2147483648; - const PARAM_INT = 1; - const PARAM_LOB = 3; - const PARAM_NULL = 0; - const PARAM_STMT = 4; - const PARAM_STR = 2; -} diff --git a/lib/Doctrine/Adapter/Db2.php b/lib/Doctrine/Adapter/Db2.php deleted file mode 100644 index c7000084f..000000000 --- a/lib/Doctrine/Adapter/Db2.php +++ /dev/null @@ -1,334 +0,0 @@ -. - */ - -/** - * Doctrine_Adapter_Db2 - * IBM DB2 Adapter [BORROWED FROM ZEND FRAMEWORK] - * - * @package Doctrine - * @subpackage Adapter - * @author Konsta Vesterinen - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.phpdoctrine.org - * @since 1.0 - * @version $Revision: 1080 $ - * @deprecated - */ -class Doctrine_Adapter_Db2 extends Doctrine_Adapter -{ - /** - * User-provided configuration. - * - * Basic keys are: - * - * username => (string) Connect to the database as this username. - * password => (string) Password associated with the username. - * host => (string) What host to connect to (default 127.0.0.1) - * dbname => (string) The name of the database to user - * protocol => (string) Protocol to use, defaults to "TCPIP" - * port => (integer) Port number to use for TCP/IP if protocol is "TCPIP" - * persistent => (boolean) Set TRUE to use a persistent connection (db2_pconnect) - * - * @var array - */ - protected $_config = array( - 'dbname' => null, - 'username' => null, - 'password' => null, - 'host' => 'localhost', - 'port' => '50000', - 'protocol' => 'TCPIP', - 'persistent' => false - ); - - /** - * Execution mode - * - * @var int execution flag (DB2_AUTOCOMMIT_ON or DB2_AUTOCOMMIT_OFF) - * @access protected - */ - protected $_execute_mode = DB2_AUTOCOMMIT_ON; - - /** - * Table name of the last accessed table for an insert operation - * This is a DB2-Adapter-specific member variable with the utmost - * probability you might not find it in other adapters... - * - * @var string - * @access protected - */ - protected $_lastInsertTable = null; - - /** - * Constructor. - * - * $config is an array of key/value pairs containing configuration - * options. These options are common to most adapters: - * - * dbname => (string) The name of the database to user - * username => (string) Connect to the database as this username. - * password => (string) Password associated with the username. - * host => (string) What host to connect to, defaults to localhost - * port => (string) The port of the database, defaults to 50000 - * persistent => (boolean) Whether to use a persistent connection or not, defaults to false - * protocol => (string) The network protocol, defaults to TCPIP - * options => (array) Other database options such as autocommit, case, and cursor options - * - * @param array $config An array of configuration keys. - */ - public function __construct(array $config) - { - if ( ! isset($config['password'])) { - throw new Doctrine_Adapter_Db2_Exception("Configuration array must have a key for 'password' for login credentials."); - } - - if ( ! isset($config['username'])) { - throw new Doctrine_Adapter_Db2_Exception("Configuration array must have a key for 'username' for login credentials."); - } - - if ( ! isset($config['dbname'])) { - throw new Doctrine_Adapter_Db2_Exception("Configuration array must have a key for 'dbname' that names the database instance."); - } - - // keep the config - $this->_config = array_merge($this->_config, (array) $config); - - // create a profiler object - $enabled = false; - if (array_key_exists('profiler', $this->_config)) { - $enabled = (bool) $this->_config['profiler']; - unset($this->_config['profiler']); - } - - $this->_profiler = new Doctrine_Profiler($enabled); - } - - /** - * Creates a connection resource. - * - * @return void - */ - protected function _connect() - { - if (is_resource($this->_connection)) { - // connection already exists - return; - } - - if ( ! extension_loaded('ibm_db2')) { - throw new Doctrine_Adapter_Db2_Exception('The IBM DB2 extension is required for this adapter but not loaded'); - } - - if ($this->_config['persistent']) { - // use persistent connection - $conn_func_name = 'db2_pconnect'; - } else { - // use "normal" connection - $conn_func_name = 'db2_connect'; - } - - if ( ! isset($this->_config['options'])) { - // config options were not set, so set it to an empty array - $this->_config['options'] = array(); - } - - if ( ! isset($this->_config['options']['autocommit'])) { - // set execution mode - $this->_config['options']['autocommit'] = &$this->_execute_mode; - } - - if ($this->_config['host'] !== 'localhost') { - // if the host isn't localhost, use extended connection params - $dbname = 'DRIVER={IBM DB2 ODBC DRIVER}' . - ';DATABASE=' . $this->_config['dbname'] . - ';HOSTNAME=' . $this->_config['host'] . - ';PORT=' . $this->_config['port'] . - ';PROTOCOL=' . $this->_config['protocol'] . - ';UID=' . $this->_config['username'] . - ';PWD=' . $this->_config['password'] .';'; - $this->_connection = $conn_func_name( - $dbname, - null, - null, - $this->_config['options'] - ); - } else { - // host is localhost, so use standard connection params - $this->_connection = $conn_func_name( - $this->_config['dbname'], - $this->_config['username'], - $this->_config['password'], - $this->_config['options'] - ); - } - - // check the connection - if ( ! $this->_connection) { - throw new Doctrine_Adapter_Db2_Exception(db2_conn_errormsg(), db2_conn_error()); - } - } - - /** - * Force the connection to close. - * - * @return void - */ - public function closeConnection() - { - db2_close($this->_connection); - $this->_connection = null; - } - - /** - * Returns an SQL statement for preparation. - * - * @param string $sql The SQL statement with placeholders. - * @return Doctrine_Statement_Db2 - */ - public function prepare($sql) - { - $this->_connect(); - $stmt = new Doctrine_Statement_Db2($this, $sql); - $stmt->setFetchMode($this->_fetchMode); - return $stmt; - } - - /** - * Gets the execution mode - * - * @return int the execution mode (DB2_AUTOCOMMIT_ON or DB2_AUTOCOMMIT_OFF) - */ - public function _getExecuteMode() - { - return $this->_execute_mode; - } - - /** - * @param integer $mode - * @return void - */ - public function _setExecuteMode($mode) - { - switch ($mode) { - case DB2_AUTOCOMMIT_OFF: - case DB2_AUTOCOMMIT_ON: - $this->_execute_mode = $mode; - db2_autocommit($this->_connection, $mode); - break; - default: - throw new Doctrine_Adapter_Db2_Exception("execution mode not supported"); - break; - } - } - - /** - * Quote a raw string. - * - * @param string $value Raw string - * @return string Quoted string - */ - protected function _quote($value) - { - /** - * Some releases of the IBM DB2 extension appear - * to be missing the db2_escape_string() method. - * The method was added in ibm_db2.c revision 1.53 - * according to cvs.php.net. But the function is - * not present in my build of PHP 5.2.1. - */ - if (function_exists('db2_escape_string')) { - return db2_escape_string($value); - } - return parent::_quote($value); - } - - /** - * @return string - */ - public function getQuoteIdentifierSymbol() - { - $info = db2_server_info($this->_connection); - $identQuote = $info->IDENTIFIER_QUOTE_CHAR; - return $identQuote; - } - - /** - * Begin a transaction. - * - * @return void - */ - protected function _beginTransaction() - { - $this->_setExecuteMode(DB2_AUTOCOMMIT_OFF); - } - - /** - * Commit a transaction. - * - * @return void - */ - protected function _commit() - { - if ( ! db2_commit($this->_connection)) { - throw new Doctrine_Adapter_Db2_Exception( - db2_conn_errormsg($this->_connection), - db2_conn_error($this->_connection)); - } - - $this->_setExecuteMode(DB2_AUTOCOMMIT_ON); - } - - /** - * Rollback a transaction. - * - * @return void - */ - protected function _rollBack() - { - if ( ! db2_rollback($this->_connection)) { - throw new Doctrine_Adapter_Db2_Exception( - db2_conn_errormsg($this->_connection), - db2_conn_error($this->_connection)); - } - $this->_setExecuteMode(DB2_AUTOCOMMIT_ON); - } - - /** - * Set the fetch mode. - * - * @param integer $mode - * @return void - */ - public function setFetchMode($mode) - { - switch ($mode) { - case Doctrine::FETCH_NUM: // seq array - case Doctrine::FETCH_ASSOC: // assoc array - case Doctrine::FETCH_BOTH: // seq+assoc array - case Doctrine::FETCH_OBJ: // object - $this->_fetchMode = $mode; - break; - default: - throw new Doctrine_Adapter_Db2_Exception('Invalid fetch mode specified'); - break; - } - } -} diff --git a/lib/Doctrine/Adapter/Db2/Exception.php b/lib/Doctrine/Adapter/Db2/Exception.php deleted file mode 100644 index 589d2468d..000000000 --- a/lib/Doctrine/Adapter/Db2/Exception.php +++ /dev/null @@ -1,34 +0,0 @@ -. - */ -Doctrine::autoload('Doctrine_Adapter_Exception'); -/** - * Doctrine_Adapter_Db2_Exception - * - * @package Doctrine - * @subpackage Adapter - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.phpdoctrine.org - * @since 1.0 - * @version $Revision$ - * @author Konsta Vesterinen - */ -class Doctrine_Adapter_Db2_Exception extends Doctrine_Adapter_Exception -{ } diff --git a/lib/Doctrine/Adapter/Exception.php b/lib/Doctrine/Adapter/Exception.php deleted file mode 100644 index 134d99895..000000000 --- a/lib/Doctrine/Adapter/Exception.php +++ /dev/null @@ -1,35 +0,0 @@ -. - */ - -/** - * Doctrine_Adapter_Exception - * - * @package Doctrine - * @subpackage Adapter - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.phpdoctrine.org - * @since 1.0 - * @version $Revision$ - * @author Konsta Vesterinen - * @deprecated - */ -class Doctrine_Adapter_Exception extends Doctrine_Exception -{ } diff --git a/lib/Doctrine/Adapter/Interface.php b/lib/Doctrine/Adapter/Interface.php deleted file mode 100644 index 9bb8427c3..000000000 --- a/lib/Doctrine/Adapter/Interface.php +++ /dev/null @@ -1,46 +0,0 @@ -. - */ - -/** - * Doctrine_Adapter_Interface - * This adapter interface should be implemented by all custom adapters - * - * @author Konsta Vesterinen - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @package Doctrine - * @subpackage Adapter - * @link www.phpdoctrine.org - * @since 1.0 - * @version $Revision$ - * @deprecated - */ -interface Doctrine_Adapter_Interface { - public function prepare($prepareString); - public function query($queryString); - public function quote($input); - public function exec($statement); - public function lastInsertId(); - public function beginTransaction(); - public function commit(); - public function rollBack(); - public function errorCode(); - public function errorInfo(); -} diff --git a/lib/Doctrine/Adapter/Mock.php b/lib/Doctrine/Adapter/Mock.php deleted file mode 100644 index c27ab9cef..000000000 --- a/lib/Doctrine/Adapter/Mock.php +++ /dev/null @@ -1,163 +0,0 @@ -. - */ - -/** - * Doctrine_Adapter_Mock - * This class is used for special testing purposes. - * - * @package Doctrine - * @subpackage Adapter - * @author Konsta Vesterinen - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.phpdoctrine.org - * @since 1.0 - * @version $Revision$ - * @deprecated - */ -class Doctrine_Adapter_Mock implements Doctrine_Adapter_Interface, Countable -{ - private $name; - - private $queries = array(); - - private $exception = array(); - - private $lastInsertIdFail = false; - - public function __construct($name = null) - { - $this->name = $name; - } - public function getName() - { - return $this->name; - } - public function pop() - { - return array_pop($this->queries); - } - public function forceException($name, $message = '', $code = 0) - { - $this->exception = array($name, $message, $code); - } - public function prepare($query) - { - $mock = new Doctrine_Adapter_Statement_Mock($this, $query); - $mock->queryString = $query; - - return $mock; - } - public function addQuery($query) - { - $this->queries[] = $query; - } - public function query($query) - { - $this->queries[] = $query; - - $e = $this->exception; - - if ( ! empty($e)) { - $name = $e[0]; - - $this->exception = array(); - - throw new $name($e[1], $e[2]); - } - - $stmt = new Doctrine_Adapter_Statement_Mock($this, $query); - $stmt->queryString = $query; - - return $stmt; - } - public function getAll() - { - return $this->queries; - } - public function quote($input) - { - return "'" . addslashes($input) . "'"; - } - public function exec($statement) - { - $this->queries[] = $statement; - - $e = $this->exception; - - if ( ! empty($e)) { - $name = $e[0]; - - $this->exception = array(); - - throw new $name($e[1], $e[2]); - } - - return 0; - } - public function forceLastInsertIdFail($fail = true) - { - if ($fail) { - $this->lastInsertIdFail = true; - } else { - $this->lastInsertIdFail = false; - } - } - public function lastInsertId() - { - $this->queries[] = 'LAST_INSERT_ID()'; - if ($this->lastInsertIdFail) { - return null; - } else { - return 1; - } - } - public function count() - { - return count($this->queries); - } - public function beginTransaction() - { - $this->queries[] = 'BEGIN TRANSACTION'; - } - public function commit() - { - $this->queries[] = 'COMMIT'; - } - public function rollBack() - { - $this->queries[] = 'ROLLBACK'; - } - public function errorCode() - { } - public function errorInfo() - { } - public function getAttribute($attribute) - { - if ($attribute == Doctrine::ATTR_DRIVER_NAME) - return strtolower($this->name); - } - public function setAttribute($attribute, $value) - { - - } - public function sqliteCreateFunction() - { } -} diff --git a/lib/Doctrine/Adapter/Mysqli.php b/lib/Doctrine/Adapter/Mysqli.php deleted file mode 100644 index d5ec741c4..000000000 --- a/lib/Doctrine/Adapter/Mysqli.php +++ /dev/null @@ -1,142 +0,0 @@ -. - */ - -/** - * Doctrine_Adapter_Mysqli - * This class is used for special testing purposes. - * - * @package Doctrine - * @subpackage Adapter - * @author Konsta Vesterinen - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.phpdoctrine.org - * @since 1.0 - * @version $Revision: 1080 $ - * @deprecated - */ -class Doctrine_Adapter_Mysqli extends Doctrine_Adapter -{ - /** - * Creates a connection to the database. - * - * @return void - * @throws Doctrine_Adapter_Mysqli_Exception - */ - protected function _connect() - { - if ($this->_connection) { - return; - } - // Suppress connection warnings here. - // Throw an exception instead. - @$this->_connection = new mysqli( - $this->_config['host'], - $this->_config['username'], - $this->_config['password'], - $this->_config['dbname'] - ); - if ($this->_connection === false || mysqli_connect_errno()) { - throw new Doctrine_Adapter_Mysqli_Exception(mysqli_connect_error()); - } - } - - /** - * Force the connection to close. - * - * @return void - */ - public function closeConnection() - { - $this->_connection->close(); - $this->_connection = null; - } - - /** - * Prepare a statement and return a PDOStatement-like object. - * - * @param string $sql SQL query - * @return Doctrine_Statement_Mysqli - */ - public function prepare($sql) - { - $this->_connect(); - $stmt = new Doctrine_Statement_Mysqli($this, $sql); - $stmt->setFetchMode($this->_fetchMode); - return $stmt; - } - - /** - * Gets the last ID generated automatically by an IDENTITY/AUTOINCREMENT column. - * - * As a convention, on RDBMS brands that support sequences - * (e.g. Oracle, PostgreSQL, DB2), this method forms the name of a sequence - * from the arguments and returns the last id generated by that sequence. - * On RDBMS brands that support IDENTITY/AUTOINCREMENT columns, this method - * returns the last value generated for such a column, and the table name - * argument is disregarded. - * - * MySQL does not support sequences, so $tableName and $primaryKey are ignored. - * - * @param string $tableName OPTIONAL Name of table. - * @param string $primaryKey OPTIONAL Name of primary key column. - * @return integer - */ - public function lastInsertId($tableName = null, $primaryKey = null) - { - $mysqli = $this->_connection; - return $mysqli->insert_id; - } - - /** - * Begin a transaction. - * - * @return void - */ - protected function _beginTransaction() - { - $this->_connect(); - $this->_connection->autocommit(false); - } - - /** - * Commit a transaction. - * - * @return void - */ - protected function _commit() - { - $this->_connect(); - $this->_connection->commit(); - $this->_connection->autocommit(true); - } - - /** - * Roll-back a transaction. - * - * @return void - */ - protected function _rollBack() - { - $this->_connect(); - $this->_connection->rollback(); - $this->_connection->autocommit(true); - } -} diff --git a/lib/Doctrine/Adapter/Oracle.php b/lib/Doctrine/Adapter/Oracle.php deleted file mode 100644 index 25fe348a1..000000000 --- a/lib/Doctrine/Adapter/Oracle.php +++ /dev/null @@ -1,272 +0,0 @@ -. - */ -Doctrine::autoload('Doctrine_Adapter'); -/** - * Doctrine_Adapter_Oracle - * [BORROWED FROM ZEND FRAMEWORK] - * - * @package Doctrine - * @subpackage Adapter - * @author Konsta Vesterinen - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.phpdoctrine.org - * @since 1.0 - * @version $Revision: 1080 $ - */ -class Doctrine_Adapter_Oracle extends Doctrine_Adapter -{ - /** - * User-provided configuration. - * - * Basic keys are: - * - * username => (string) Connect to the database as this username. - * password => (string) Password associated with the username. - * dbname => Either the name of the local Oracle instance, or the - * name of the entry in tnsnames.ora to which you want to connect. - * - * @var array - */ - protected $_config = array( - 'dbname' => null, - 'username' => null, - 'password' => null, - ); - - /** - * @var integer - */ - protected $_execute_mode = OCI_COMMIT_ON_SUCCESS; - - /** - * Constructor. - * - * $config is an array of key/value pairs containing configuration - * options. These options are common to most adapters: - * - * username => (string) Connect to the database as this username. - * password => (string) Password associated with the username. - * dbname => Either the name of the local Oracle instance, or the - * name of the entry in tnsnames.ora to which you want to connect. - * - * @param array $config An array of configuration keys. - * @throws Doctrine_Adapter_Exception - */ - public function __construct(array $config) - { - if ( ! isset($config['password']) || ! isset($config['username'])) { - throw new Doctrine_Adapter_Exception('config array must have at least a username and a password'); - } - - // @todo Let this protect backward-compatibility for one release, then remove - if ( ! isset($config['database']) || ! isset($config['dbname'])) { - $config['dbname'] = $config['database']; - unset($config['database']); - trigger_error("Deprecated config key 'database', use 'dbname' instead.", E_USER_NOTICE); - } - - // keep the config - $this->_config = array_merge($this->_config, (array) $config); - - // create a profiler object - $enabled = false; - if (array_key_exists('profiler', $this->_config)) { - $enabled = (bool) $this->_config['profiler']; - unset($this->_config['profiler']); - } - - $this->_profiler = new Doctrine_Profiler($enabled); - } - - /** - * Creates a connection resource. - * - * @return void - * @throws Doctrine_Adapter_Oracle_Exception - */ - protected function _connect() - { - if (is_resource($this->_connection)) { - // connection already exists - return; - } - - if ( ! extension_loaded('oci8')) { - throw new Doctrine_Adapter_Oracle_Exception('The OCI8 extension is required for this adapter but not loaded'); - } - - if (isset($this->_config['dbname'])) { - $this->_connection = @oci_connect( - $this->_config['username'], - $this->_config['password'], - $this->_config['dbname']); - } else { - $this->_connection = oci_connect( - $this->_config['username'], - $this->_config['password']); - } - - // check the connection - if ( ! $this->_connection) { - throw new Doctrine_Adapter_Oracle_Exception(oci_error()); - } - } - - /** - * Force the connection to close. - * - * @return void - */ - public function closeConnection() - { - if (is_resource($this->_connection)) { - oci_close($this->_connection); - } - $this->_connection = null; - } - - /** - * Returns an SQL statement for preparation. - * - * @param string $sql The SQL statement with placeholders. - * @return Doctrine_Statement_Oracle - */ - public function prepare($sql) - { - $this->_connect(); - $stmt = new Doctrine_Statement_Oracle($this, $sql); - $stmt->setFetchMode($this->_fetchMode); - return $stmt; - } - - /** - * Quote a raw string. - * - * @param string $value Raw string - * @return string Quoted string - */ - protected function _quote($value) - { - $value = str_replace("'", "''", $value); - return "'" . addcslashes($value, "\000\n\r\\\032") . "'"; - } - - /** - * Quote a table identifier and alias. - * - * @param string|array|Doctrine_Expr $ident The identifier or expression. - * @param string $alias An alias for the table. - * @return string The quoted identifier and alias. - */ - public function quoteTableAs($ident, $alias) - { - // Oracle doesn't allow the 'AS' keyword between the table identifier/expression and alias. - return $this->_quoteIdentifierAs($ident, $alias, ' '); - } - - /** - * Leave autocommit mode and begin a transaction. - * - * @return void - */ - protected function _beginTransaction() - { - $this->_setExecuteMode(OCI_DEFAULT); - } - - /** - * Commit a transaction and return to autocommit mode. - * - * @return void - * @throws Doctrine_Adapter_Oracle_Exception - */ - protected function _commit() - { - if ( ! oci_commit($this->_connection)) { - throw new Doctrine_Adapter_Oracle_Exception(oci_error($this->_connection)); - } - $this->_setExecuteMode(OCI_COMMIT_ON_SUCCESS); - } - - /** - * Roll back a transaction and return to autocommit mode. - * - * @return void - * @throws Doctrine_Adapter_Oracle_Exception - */ - protected function _rollBack() - { - if ( ! oci_rollback($this->_connection)) { - throw new Doctrine_Adapter_Oracle_Exception(oci_error($this->_connection)); - } - $this->_setExecuteMode(OCI_COMMIT_ON_SUCCESS); - } - - /** - * Set the fetch mode. - * - * @todo Support FETCH_CLASS and FETCH_INTO. - * - * @param integer $mode A fetch mode. - * @return void - * @throws Doctrine_Adapter_Exception - */ - public function setFetchMode($mode) - { - switch ($mode) { - case Doctrine::FETCH_NUM: // seq array - case Doctrine::FETCH_ASSOC: // assoc array - case Doctrine::FETCH_BOTH: // seq+assoc array - case Doctrine::FETCH_OBJ: // object - $this->_fetchMode = $mode; - break; - default: - throw new Doctrine_Adapter_Exception('Invalid fetch mode specified'); - break; - } - } - - /** - * @param integer $mode - * @throws Doctrine_Adapter_Exception - */ - private function _setExecuteMode($mode) - { - switch($mode) { - case OCI_COMMIT_ON_SUCCESS: - case OCI_DEFAULT: - case OCI_DESCRIBE_ONLY: - $this->_execute_mode = $mode; - break; - default: - throw new Doctrine_Adapter_Exception('wrong execution mode specified'); - break; - } - } - - /** - * @return - */ - public function _getExecuteMode() - { - return $this->_execute_mode; - } -} diff --git a/lib/Doctrine/Adapter/Resource.php b/lib/Doctrine/Adapter/Resource.php deleted file mode 100644 index 3ce42ef23..000000000 --- a/lib/Doctrine/Adapter/Resource.php +++ /dev/null @@ -1,108 +0,0 @@ -. - */ - -/** - * Doctrine_Adapter_Resource - * - * @author Konsta Vesterinen - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @package Doctrine - * @subpackage Adapter - * @link www.phpdoctrine.org - * @since 1.0 - * @version $Revision: 2702 $ - * @deprecated - * @todo Remove - */ -class Doctrine_Adapter_Resource implements Doctrine_Adapter_Interface -{ - protected $resourceUrl; - - public function __construct($resourceUrl) - { - $this->resourceUrl = $resourceUrl; - } - - public function prepare($sql) - { - - } - - public function query($sql) - { - - } - - public function quote($input) - { - - } - - public function exec($sql) - { - - } - - public function lastInsertId() - { - - } - - public function beginTransaction() - { - - } - - public function commit() - { - - } - - public function rollBack() - { - - } - - public function errorCode() - { - - } - - public function errorInfo() - { - - } - - public function getAttribute() - { - return 'sqlite'; - } - - public function setAttribute() - { - - } - - public function sqliteCreateFunction() - { - - } -} \ No newline at end of file diff --git a/lib/Doctrine/Adapter/Statement.php b/lib/Doctrine/Adapter/Statement.php deleted file mode 100644 index 682d04331..000000000 --- a/lib/Doctrine/Adapter/Statement.php +++ /dev/null @@ -1,90 +0,0 @@ -. - */ - -/** - * Doctrine_Adapter_Statement - * - * @author Konsta Vesterinen - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @package Doctrine - * @subpackage Adapter - * @link www.phpdoctrine.org - * @since 1.0 - * @version $Revision$ - */ -abstract class Doctrine_Adapter_Statement -{ - public function bindValue($no, $value) - { - } - - /** - * 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() - { - } - public function nextRowset() - { - } - public function execute() - { - } - public function errorCode() - { - } - public function errorInfo() - { - } - public function rowCount() - { - } - public function setFetchMode($mode) - { - } - public function columnCount() - { - } -} diff --git a/lib/Doctrine/Adapter/Statement/Interface.php b/lib/Doctrine/Adapter/Statement/Interface.php deleted file mode 100644 index 50aee68d1..000000000 --- a/lib/Doctrine/Adapter/Statement/Interface.php +++ /dev/null @@ -1,294 +0,0 @@ -. - */ - -/** - * Doctrine_Adapter_Statement - * - * @author Konsta Vesterinen - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @package Doctrine - * @subpackage Adapter - * @link www.phpdoctrine.org - * @since 1.0 - * @version $Revision$ - * @deprecated - */ -interface Doctrine_Adapter_Statement_Interface -{ - /** - * bindColumn - * 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); - - /** - * 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); - - /** - * bindParam - * 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()); - - /** - * closeCursor - * Closes the cursor, enabling the statement to be executed again. - * - * @return boolean Returns TRUE on success or FALSE on failure. - */ - public function closeCursor(); - - /** - * columnCount - * 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(); - - /** - * errorCode - * 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(); - - /** - * errorInfo - * 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(); - - /** - * execute - * 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); - - /** - * 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($fetchStyle = Doctrine::FETCH_BOTH, - $cursorOrientation = Doctrine::FETCH_ORI_NEXT, - $cursorOffset = null); - - /** - * fetchAll - * Returns an array containing all of the result set rows - * - * @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 $columnIndex Returns the indicated 0-indexed column when the value of $fetchStyle is - * Doctrine::FETCH_COLUMN. Defaults to 0. - * - * @return array - */ - public function fetchAll($fetchStyle = Doctrine::FETCH_BOTH); - - /** - * fetchColumn - * 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); - - /** - * fetchObject - * 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()); - - /** - * getAttribute - * Retrieve a statement attribute - * - * @param integer $attribute - * @see Doctrine::ATTR_* constants - * @return mixed the attribute value - */ - public function getAttribute($attribute); - - /** - * getColumnMeta - * 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); - - /** - * nextRowset - * 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(); - - /** - * rowCount - * 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(); - - /** - * setAttribute - * 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); - - /** - * setFetchMode - * 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); -} diff --git a/lib/Doctrine/Adapter/Statement/Mock.php b/lib/Doctrine/Adapter/Statement/Mock.php deleted file mode 100644 index 6ba46b249..000000000 --- a/lib/Doctrine/Adapter/Statement/Mock.php +++ /dev/null @@ -1,349 +0,0 @@ -. - */ - -/** - * Doctrine_Adapter_Statement_Mock - * This class is used for special testing purposes. - * - * @package Doctrine - * @subpackage Adapter - * @author Konsta Vesterinen - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.phpdoctrine.org - * @since 1.0 - * @version $Revision$ - */ -class Doctrine_Adapter_Statement_Mock implements Doctrine_Adapter_Statement_Interface -{ - private $mock; - - public $queryString; - - public function __construct($mock) - { - $this->mock = $mock; - } - - /** - * bindColumn - * 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) - { - - } - - /** - * 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) - { - - } - - /** - * bindParam - * 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()) - { - - } - - /** - * closeCursor - * Closes the cursor, enabling the statement to be executed again. - * - * @return boolean Returns TRUE on success or FALSE on failure. - */ - public function closeCursor() - { - return true; - } - - /** - * columnCount - * 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 0; - } - - /** - * errorCode - * 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 array(); - } - - /** - * errorInfo - * 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 array(); - } - - /** - * 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($fetchStyle = Doctrine::FETCH_BOTH, - $cursorOrientation = Doctrine::FETCH_ORI_NEXT, - $cursorOffset = null) - { - return array(); - } - - /** - * fetchAll - * Returns an array containing all of the result set rows - * - * @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 $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) - { - return array(); - } - - /** - * execute - * 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) - { - if (is_object($this->mock)) { - $this->mock->addQuery($this->queryString); - } - return true; - } - - /** - * fetchColumn - * 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 0; - } - - /** - * fetchObject - * 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 new $className(); - } - - /** - * nextRowset - * 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 true; - } - - /** - * rowCount - * 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 0; - } - - /** - * getColumnMeta - * 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) - { } - /** - * getAttribute - * Retrieve a statement attribute - * - * @param integer $attribute - * @see Doctrine::ATTR_* constants - * @return mixed the attribute value - */ - public function getAttribute($attribute) - { } - /** - * setAttribute - * 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) - { } - /** - * setFetchMode - * 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) - { } -} diff --git a/lib/Doctrine/ConnectionFactory.php b/lib/Doctrine/ConnectionFactory.php deleted file mode 100644 index ab6f36ccc..000000000 --- a/lib/Doctrine/ConnectionFactory.php +++ /dev/null @@ -1,112 +0,0 @@ -. - */ - -#namespace Doctrine::DBAL; - -/** - * Factory for creating dbms-specific Connection instances. - * - * @author Roman Borschel - * @since 2.0 - */ -class Doctrine_ConnectionFactory -{ - /** - * List of supported drivers and their mappings to the driver class. - * - * @var array - */ - private $_drivers = array( - 'mysql' => 'Doctrine_Connection_Mysql', - 'sqlite' => 'Doctrine_Connection_Sqlite', - 'pgsql' => 'Doctrine_Connection_Pgsql', - 'oci' => 'Doctrine_Connection_Oracle', - 'oci8' => 'Doctrine_Connection_Oracle', - 'oracle' => 'Doctrine_Connection_Oracle', - 'mssql' => 'Doctrine_Connection_Mssql', - 'dblib' => 'Doctrine_Connection_Mssql', - 'firebird' => 'Doctrine_Connection_Firebird', - 'informix' => 'Doctrine_Connection_Informix', - ); - - public function __construct() - { - - } - - /** - * Creates a connection object with the specified parameters. - * - * @param array $params - * @return Connection - */ - public function createConnection(array $params, Doctrine_Common_Configuration $config = null, - Doctrine_Common_EventManager $eventManager = null) - { - // create default config and event manager, if not set - if ( ! $config) { - $config = new Doctrine_Common_Configuration(); - } - if ( ! $eventManager) { - $eventManager = new Doctrine_Common_EventManager(); - } - - // check for existing pdo object - if (isset($params['pdo']) && ! $params['pdo'] instanceof PDO) { - throw Doctrine_ConnectionFactory_Exception::invalidPDOInstance(); - } else if (isset($params['pdo'])) { - $params['driver'] = $params['pdo']->getAttribute(PDO::ATTR_DRIVER_NAME); - } else { - $this->_checkParams($params); - } - if (isset($params['driverClass'])) { - $className = $params['driverClass']; - } else { - $className = $this->_drivers[$params['driver']]; - } - - return new $className($params, $config, $eventManager); - } - - /** - * Checks the list of parameters. - * - * @param array $params - */ - private function _checkParams(array $params) - { - // check existance of mandatory parameters - - // driver - if ( ! isset($params['driver']) && ! isset($params['driverClass'])) { - throw Doctrine_ConnectionFactory_Exception::driverRequired(); - } - - // check validity of parameters - - // driver - if ( isset($params['driver']) && ! isset($this->_drivers[$params['driver']])) { - throw Doctrine_ConnectionFactory_Exception::unknownDriver($params['driver']); - } - } -} - -?> \ No newline at end of file diff --git a/lib/Doctrine/ConnectionFactory/Exception.php b/lib/Doctrine/ConnectionFactory/Exception.php deleted file mode 100644 index aff749c07..000000000 --- a/lib/Doctrine/ConnectionFactory/Exception.php +++ /dev/null @@ -1,49 +0,0 @@ -. - */ - -/** - * Doctrine_ConnectionFactory_Exception - * - * @package Doctrine - * @subpackage Hydrate - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.phpdoctrine.org - * @since 1.0 - * @version $Revision: 1080 $ - * @author Konsta Vesterinen - */ -class Doctrine_ConnectionFactory_Exception extends Doctrine_Exception -{ - public static function invalidPDOInstance() - { - return new self("Invalid PDO instance provided on connection creation."); - } - - public static function driverRequired() - { - return new self("Please provide a driver or a driverClass to be able to start a Connection."); - } - - public static function unknownDriver($driver) - { - return new self("Unknown Connection driver '$driver'."); - } -} \ No newline at end of file diff --git a/lib/Doctrine/EntityManager.php b/lib/Doctrine/EntityManager.php index 8136ccca7..0459e2cd3 100644 --- a/lib/Doctrine/EntityManager.php +++ b/lib/Doctrine/EntityManager.php @@ -702,8 +702,8 @@ class Doctrine_EntityManager Doctrine_EventManager $eventManager = null) { if (is_array($conn)) { - $connFactory = new Doctrine_ConnectionFactory(); - $conn = $connFactory->createConnection($conn, $config, $eventManager); + $connFactory = new Doctrine_DBAL_DriverManager(); + $conn = $connFactory->getConnection($conn, $config, $eventManager); } else if ( ! $conn instanceof Doctrine_Connection) { throw new Doctrine_Exception("Invalid parameter '$conn'."); } diff --git a/tests/lib/Doctrine_TestUtil.php b/tests/lib/Doctrine_TestUtil.php index 9a3b17b31..fc0bf4ea4 100644 --- a/tests/lib/Doctrine_TestUtil.php +++ b/tests/lib/Doctrine_TestUtil.php @@ -4,7 +4,7 @@ class Doctrine_TestUtil { public static function getConnection() { - $connFactory = new Doctrine_ConnectionFactory(); + $connFactory = new Doctrine_DBAL_DriverManager(); if (isset($GLOBALS['db_type'], $GLOBALS['db_username'], $GLOBALS['db_password'], $GLOBALS['db_host'], $GLOBALS['db_name'])) { @@ -24,7 +24,7 @@ class Doctrine_TestUtil ); } - return $connFactory->createConnection($params); + return $connFactory->getConnection($params); } /* public static function autoloadModel($className)