1
0
mirror of synced 2024-12-12 22:36:02 +03:00

Intermediate checkin. Refactoring towards namespaced structure.

This commit is contained in:
romanb 2008-09-12 08:51:56 +00:00
parent ad4db34a87
commit 4d7b8838cc
80 changed files with 2863 additions and 463 deletions

View File

@ -18,7 +18,7 @@
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
Doctrine::autoload('Doctrine_Adapter');
/**
* Doctrine_Adapter_Db2
* IBM DB2 Adapter [BORROWED FROM ZEND FRAMEWORK]
@ -30,6 +30,7 @@ Doctrine::autoload('Doctrine_Adapter');
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision: 1080 $
* @deprecated
*/
class Doctrine_Adapter_Db2 extends Doctrine_Adapter
{

View File

@ -18,7 +18,7 @@
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
Doctrine::autoload('Doctrine_Exception');
/**
* Doctrine_Adapter_Exception
*
@ -28,7 +28,8 @@ Doctrine::autoload('Doctrine_Exception');
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @deprecated
*/
class Doctrine_Adapter_Exception extends Doctrine_Exception
{ }

View File

@ -29,7 +29,8 @@
* @subpackage Adapter
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision$
* @version $Revision$
* @deprecated
*/
interface Doctrine_Adapter_Interface {
public function prepare($prepareString);

View File

@ -29,7 +29,8 @@
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision$
* @version $Revision$
* @deprecated
*/
class Doctrine_Adapter_Mock implements Doctrine_Adapter_Interface, Countable
{

View File

@ -30,6 +30,7 @@
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision: 1080 $
* @deprecated
*/
class Doctrine_Adapter_Mysqli extends Doctrine_Adapter
{

View File

@ -28,7 +28,9 @@
* @subpackage Adapter
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision: 2702 $
* @version $Revision: 2702 $
* @deprecated
* @todo Remove
*/
class Doctrine_Adapter_Resource implements Doctrine_Adapter_Interface
{

View File

@ -28,7 +28,8 @@
* @subpackage Adapter
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision$
* @version $Revision$
* @deprecated
*/
interface Doctrine_Adapter_Statement_Interface
{

View File

@ -1,6 +1,6 @@
<?php
#namespace Doctrine::ORM::Mappings;
#namespace Doctrine::ORM::Mapping;
/**
* A many-to-many mapping describes the mapping between two collections of

View File

@ -19,7 +19,7 @@
* <http://www.phpdoctrine.org>.
*/
#namespace Doctrine::ORM::Mappings;
#namespace Doctrine::ORM::Mapping;
/**
* Represents a one-to-many mapping.

View File

@ -19,19 +19,16 @@
* <http://www.phpdoctrine.org>.
*/
#namespace Doctrine::Common::Cache;
#namespace Doctrine::ORM::Cache;
/**
* Doctrine_Cache_Apc
* APC cache driver.
*
* @package Doctrine
* @subpackage Cache
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @todo Rename to ApcCache
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_Cache_Apc extends Doctrine_Cache_Driver
{

View File

@ -20,17 +20,15 @@
*/
/**
* Doctrine_Cache_Interface
* Array cache driver.
*
* @package Doctrine
* @subpackage Cache
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_Cache_Array implements Countable, Doctrine_Cache_Interface
class Doctrine_Cache_Array implements Doctrine_Cache_Interface
{
/**
* @var array $data an array of cached data

View File

@ -20,10 +20,8 @@
*/
/**
* Doctrine_Cache_Driver
* Base class for cache drivers.
*
* @package Doctrine
* @subpackage Cache
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0

View File

@ -20,10 +20,8 @@
*/
/**
* Doctrine_Cache_Memcache
* Memcache cache driver.
*
* @package Doctrine
* @subpackage Cache
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0

View File

@ -20,10 +20,8 @@
*/
/**
* Doctrine_Cache_Xcache
* Xcache cache driver.
*
* @package Doctrine
* @subpackage Cache
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0

View File

@ -19,14 +19,14 @@
* <http://www.phpdoctrine.org>.
*/
#namespace Doctrine::ORM::Internal;
/**
* The code metadata driver loads the metadata of the classes through invoking
* a static callback method that needs to be implemented when using this driver.
*
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Roman Borschel <roman@code-factory.org>
* @package Doctrine
* @subpackage ClassMetadata
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @version $Revision$
* @link www.phpdoctrine.org

View File

@ -1,3 +1,3 @@
<?php
//@deprecated
class Doctrine_ClassMetadata_Exception extends Doctrine_Exception {}

View File

@ -22,7 +22,7 @@
#namespace Doctrine::ORM;
/**
* A persistent collection of entities.
* A persistent collection.
*
* A collection object is strongly typed in the sense that it can only contain
* entities of a specific type or one of it's subtypes. A collection object is

View File

@ -28,7 +28,8 @@
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @deprecated
*/
class Doctrine_Collection_Exception extends Doctrine_Exception
{ }

View File

@ -29,7 +29,8 @@
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @deprecated
*/
abstract class Doctrine_Collection_Iterator implements Iterator
{

View File

@ -18,7 +18,7 @@
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
Doctrine::autoload('Doctrine_Collection_Iterator');
/**
* Doctrine_Collection_Iterator_Normal
*
@ -28,7 +28,8 @@ Doctrine::autoload('Doctrine_Collection_Iterator');
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @deprecated
*/
class Doctrine_Collection_Iterator_Expandable extends Doctrine_Collection_Iterator
{

View File

@ -18,7 +18,7 @@
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
Doctrine::autoload('Doctrine_Collection_Iterator');
/**
* Doctrine_Collection_Iterator_Normal
*
@ -28,7 +28,8 @@ Doctrine::autoload('Doctrine_Collection_Iterator');
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @deprecated
*/
class Doctrine_Collection_Iterator_Normal extends Doctrine_Collection_Iterator
{

View File

@ -18,7 +18,7 @@
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
Doctrine::autoload('Doctrine_Collection_Iterator');
/**
* Doctrine_Collection_Iterator_Normal
*
@ -28,7 +28,8 @@ Doctrine::autoload('Doctrine_Collection_Iterator');
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @deprecated
*/
class Doctrine_Collection_Iterator_Offset extends Doctrine_Collection_Iterator
{

View File

@ -28,7 +28,8 @@
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @deprecated
*/
class Doctrine_Collection_Offset extends Doctrine_Collection
{

View File

@ -28,7 +28,8 @@
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision$
* @version $Revision$
* @deprecated
*/
class Doctrine_Compiler_Exception extends Doctrine_Exception
{ }

View File

@ -19,27 +19,15 @@
* <http://www.phpdoctrine.org>.
*/
#namespace Doctrine::DBAL::Connections;
#namespace Doctrine::DBAL;
#use Doctrine::Common::Configuration;
#use Doctrine::Common::EventManager;
#use Doctrine::DBAL::Exceptions::ConnectionException;
/**
* A thin wrapper on top of the PDO class.
*
* 1. Event listeners
* An easy to use, pluggable eventlistener architecture. Aspects such as
* logging, query profiling and caching can be easily implemented through
* the use of these listeners
*
* 2. Lazy-connecting
* Creating an instance of Doctrine_Connection does not connect
* to database. Connecting to database is only invoked when actually needed
* (for example when query() is being called)
*
* 3. Convenience methods
* Doctrine_Connection provides many convenience methods such as fetchAll(), fetchOne() etc.
* A wrapper around a Doctrine::DBAL::Connection that adds features like
* events, configuration, emulated transaction nesting and more.
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @since 1.0
@ -64,8 +52,9 @@
*
* 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
*/
abstract class Doctrine_Connection
class Doctrine_Connection
{
/**
* The PDO database handle.
@ -114,6 +103,13 @@ abstract class Doctrine_Connection
*/
protected $_serverInfo = array();
/**
* The transaction nesting level.
*
* @var integer
*/
protected $_transactionNestingLevel = 0;
/**
* The parameters used during creation of the Connection.
*
@ -183,11 +179,33 @@ abstract class Doctrine_Connection
}
// create platform
$class = "Doctrine_DatabasePlatform_" . $this->_driverName . "Platform";
$class = "Doctrine_DBAL_Platforms_" . $this->_driverName . "Platform";
$this->_platform = new $class();
$this->_platform->setQuoteIdentifiers($this->_config->getQuoteIdentifiers());
}
public function __construct2(array $params, Doctrine_DBAL_Driver $driver,
Doctrine_Configuration $config = null, Doctrine_EventManager $eventManager = null)
{
$this->_driver = $driver;
$this->_params = $params;
if (isset($params['pdo'])) {
$this->_pdo = $params['pdo'];
$this->_isConnected = true;
}
// Create default config and event manager if none given
if ( ! $config) {
$this->_config = new Doctrine_Configuration();
}
if ( ! $eventManager) {
$this->_eventManager = new Doctrine_EventManager();
}
$this->_platform = $driver->getDatabasePlatform();
}
/**
* Gets the Configuration used by the Connection.
*
@ -232,27 +250,6 @@ abstract class Doctrine_Connection
{
return PDO::getAvailableDrivers();
}
/**
* returns the name of this driver
*
* @return string the name of this driver
*/
public function getName()
{
return $this->_name;
}
/**
* Sets the name of the connection
*
* @param string $name
* @return void
*/
public function setName($name)
{
$this->_name = $name;
}
/**
* Gets the name of the instance driver
@ -286,9 +283,6 @@ abstract class Doctrine_Connection
return false;
}
//$event = new Doctrine_Event($this, Doctrine_Event::CONN_CONNECT);
//$this->getListener()->preConnect($event);
// 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]);
@ -309,18 +303,36 @@ abstract class Doctrine_Connection
$this->_pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$this->_pdo->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER);
// attach the pending attributes to adapter
/*foreach($this->pendingAttributes as $attr => $value) {
// some drivers don't support setting this so we just skip it
if ($attr == Doctrine::ATTR_DRIVER_NAME) {
continue;
}
$this->_pdo->setAttribute($attr, $value);
}*/
$this->_isConnected = true;
return true;
}
/**
* Establishes the connection with the database.
*
* @return boolean
*/
public function connect2()
{
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->_pdo = $this->_driver->connect($this->_params, $user, $password, $driverOptions);
$this->_pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$this->_pdo->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER);
$this->_isConnected = true;
//$this->getListener()->postConnect($event);
return true;
}
@ -337,70 +349,6 @@ abstract class Doctrine_Connection
{
throw Doctrine_Exception::notImplemented('_constructPdoDsn', get_class($this));
}
/**
* Execute a SQL REPLACE query. A REPLACE query is identical to a INSERT
* query, except that if there is already a row in the table with the same
* key field values, the REPLACE query just updates its values instead of
* inserting a new row.
*
* The REPLACE type of query does not make part of the SQL standards. Since
* practically only MySQL and SQLite implement it natively, this type of
* query is emulated through this method for other DBMS using standard types
* of queries inside a transaction to assure the atomicity of the operation.
*
* @param string name of the table on which the REPLACE query will
* be executed.
*
* @param array an associative array that describes the fields and the
* values that will be inserted or updated in the specified table. The
* indexes of the array are the names of all the fields of the table.
*
* The values of the array are values to be assigned to the specified field.
*
* @param array $keys an array containing all key fields (primary key fields
* or unique index fields) for this table
*
* the uniqueness of a row will be determined according to
* the provided key fields
*
* this method will fail if no key fields are specified
*
* @throws Doctrine_Connection_Exception if this driver doesn't support replace
* @throws Doctrine_Connection_Exception if some of the key values was null
* @throws Doctrine_Connection_Exception if there were no key fields
* @throws PDOException if something fails at PDO level
* @return integer number of rows affected
*/
public function replace($tableName, array $data, array $keys)
{
if (empty($keys)) {
throw new Doctrine_Connection_Exception('Not specified which fields are keys');
}
$condition = $values = array();
foreach ($data as $columnName => $value) {
$values[$columnName] = $value;
if (in_array($columnName, $keys)) {
if ($value === null)
throw new Doctrine_Connection_Exception('key value '.$columnName.' may not be null');
$condition[] = $columnName . ' = ?';
$conditionValues[] = $value;
}
}
$query = 'DELETE FROM ' . $this->quoteIdentifier($tableName)
. ' WHERE ' . implode(' AND ', $condition);
$affectedRows = $this->exec($query, $conditionValues);
$this->insert($table, $values);
$affectedRows++;
return $affectedRows;
}
/**
* Deletes table row(s) matching the specified identifier.
@ -502,7 +450,7 @@ abstract class Doctrine_Connection
*/
public function setCharset($charset)
{
return true;
$this->exec($this->_platform->getSetCharsetSql($charset));
}
/**
@ -541,52 +489,7 @@ abstract class Doctrine_Connection
*/
public function quoteIdentifier($str)
{
/*if (is_null($this->_quoteIdentifiers)) {
$this->_quoteIdentifiers = $this->_config->get('quoteIdentifiers');
}
if ( ! $this->_quoteIdentifiers) {
return $str;
}
// quick fix for the identifiers that contain a dot
if (strpos($str, '.')) {
$e = explode('.', $str);
return $this->quoteIdentifier($e[0])
. '.'
. $this->quoteIdentifier($e[1]);
}
$c = $this->_platform->getIdentifierQuoteCharacter();
$str = str_replace($c, $c . $c, $str);
return $c . $str . $c;*/
return $this->getDatabasePlatform()->quoteIdentifier($str);
}
/**
* Some drivers need the boolean values to be converted into integers
* when using DQL API.
*
* This method takes care of that conversion
*
* @param array $item
* @return void
* @deprecated Moved to DatabasePlatform
*/
public function convertBooleans($item)
{
if (is_array($item)) {
foreach ($item as $k => $value) {
if (is_bool($value)) {
$item[$k] = (int) $value;
}
}
} else {
if (is_bool($item)) {
$item = (int) $item;
}
}
return $item;
return $this->_platform->quoteIdentifier($str);
}
/**
@ -601,17 +504,6 @@ abstract class Doctrine_Connection
return $this->_pdo->quote($input, $type);
}
/**
* Set the date/time format for the current connection
*
* @param string time format
*
* @return void
*/
public function setDateFormat($format = null)
{
}
/**
* fetchAll
*
@ -706,19 +598,8 @@ abstract class Doctrine_Connection
public function prepare($statement)
{
$this->connect();
try {
//$event = new Doctrine_Event($this, Doctrine_Event::CONN_PREPARE, $statement);
//$this->getAttribute(Doctrine::ATTR_LISTENER)->prePrepare($event);
$stmt = false;
//if ( ! $event->skipOperation) {
$stmt = $this->_pdo->prepare($statement);
//}
//$this->getAttribute(Doctrine::ATTR_LISTENER)->postPrepare($event);
$stmt = $this->_pdo->prepare($statement);
return new Doctrine_Connection_Statement($this, $stmt);
} catch (PDOException $e) {
$this->rethrowException($e, $this);
@ -742,19 +623,6 @@ abstract class Doctrine_Connection
return $this->execute($query);
}
/**
* standaloneQuery
*
* @param string $query sql query
* @param array $params query parameters
*
* @return PDOStatement|Doctrine_Adapter_Statement
*/
public function standaloneQuery($query, $params = array())
{
return $this->execute($query, $params);
}
/**
* Executes an SQL SELECT query with the given parameters.
*
@ -766,22 +634,14 @@ abstract class Doctrine_Connection
public function execute($query, array $params = array())
{
$this->connect();
try {
if ( ! empty($params)) {
$stmt = $this->prepare($query);
$stmt->execute($params);
return $stmt;
} else {
//$event = new Doctrine_Event($this, Doctrine_Event::CONN_QUERY, $query, $params);
//$this->getAttribute(Doctrine::ATTR_LISTENER)->preQuery($event);
//if ( ! $event->skipOperation) {
$stmt = $this->_pdo->query($query);
$this->_queryCount++;
//}
//$this->getAttribute(Doctrine::ATTR_LISTENER)->postQuery($event);
$stmt = $this->_pdo->query($query);
$this->_queryCount++;
return $stmt;
}
} catch (PDOException $e) {
@ -800,23 +660,14 @@ abstract class Doctrine_Connection
*/
public function exec($query, array $params = array()) {
$this->connect();
try {
if ( ! empty($params)) {
$stmt = $this->prepare($query);
$stmt->execute($params);
return $stmt->rowCount();
} else {
//$event = new Doctrine_Event($this, Doctrine_Event::CONN_EXEC, $query, $params);
//$this->getAttribute(Doctrine::ATTR_LISTENER)->preExec($event);
//if ( ! $event->skipOperation) {
$count = $this->_pdo->exec($query);
$this->_queryCount++;
//}
//$this->getAttribute(Doctrine::ATTR_LISTENER)->postExec($event);
$count = $this->_pdo->exec($query);
$this->_queryCount++;
return $count;
}
} catch (PDOException $e) {
@ -830,13 +681,7 @@ abstract class Doctrine_Connection
* @throws Doctrine_Connection_Exception
*/
public function rethrowException(Exception $e, $invoker)
{
$name = 'Doctrine_Connection_' . $this->_driverName . '_Exception';
$exc = new $name($e->getMessage(), (int) $e->getCode());
if ( ! is_array($e->errorInfo)) {
$e->errorInfo = array(null, null, null, null);
}
$exc->processErrorInfo($e->errorInfo);
{
throw $exc;
}
@ -858,14 +703,9 @@ abstract class Doctrine_Connection
*/
public function close()
{
//$event = new Doctrine_Event($this, Doctrine_Event::CONN_CLOSE);
//this->getAttribute(Doctrine::ATTR_LISTENER)->preClose($event);
$this->clear();
unset($this->_pdo);
$this->_isConnected = false;
//$this->getAttribute(Doctrine::ATTR_LISTENER)->postClose($event);
}
/**
@ -875,7 +715,7 @@ abstract class Doctrine_Connection
*/
public function getTransactionLevel()
{
return $this->transaction->getTransactionLevel();
return $this->_transaction->getTransactionLevel();
}
/**
@ -886,7 +726,6 @@ abstract class Doctrine_Connection
public function errorCode()
{
$this->connect();
return $this->_pdo->errorCode();
}
@ -898,7 +737,6 @@ abstract class Doctrine_Connection
public function errorInfo()
{
$this->connect();
return $this->_pdo->errorInfo();
}
@ -921,17 +759,19 @@ abstract class Doctrine_Connection
* Start a transaction or set a savepoint.
*
* if trying to set a savepoint and there is no active transaction
* a new transaction is being started
*
* Listeners: onPreTransactionBegin, onTransactionBegin
* 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
*/
public function beginTransaction($savepoint = null)
public function beginTransaction()
{
return $this->_transaction->beginTransaction($savepoint);
if ($this->_transactionNestingLevel == 0) {
return $this->_pdo->beginTransaction();
}
++$this->_transactionNestingLevel;
return true;
}
/**
@ -939,16 +779,25 @@ abstract class Doctrine_Connection
* progress or release a savepoint. This function may only be called when
* auto-committing is disabled, otherwise it will fail.
*
* Listeners: onPreTransactionCommit, onTransactionCommit
*
* @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
*/
public function commit($savepoint = null)
public function commit()
{
return $this->_transaction->commit($savepoint);
if ($this->_transactionNestingLevel == 0) {
throw new Doctrine_Exception("Commit failed. There is no active transaction.");
}
$this->connect();
if ($this->_transactionNestingLevel == 1) {
return $this->_pdo->commit();
}
--$this->_transactionNestingLevel;
return true;
}
/**
@ -964,73 +813,22 @@ abstract class Doctrine_Connection
* @throws Doctrine_Transaction_Exception If the rollback operation fails at database level.
* @return boolean FALSE if rollback couldn't be performed, TRUE otherwise.
*/
public function rollback($savepoint = null)
public function rollback()
{
$this->_transaction->rollback($savepoint);
}
/**
* Creates the database for the connection instance.
*
* @return mixed Will return an instance of the exception thrown if the
* create database fails, otherwise it returns a string
* detailing the success.
*/
public function createDatabase()
{
try {
if ( ! $dsn = $this->getOption('dsn')) {
throw new Doctrine_Connection_Exception('You must create your Doctrine_Connection by using a valid Doctrine style dsn in order to use the create/drop database functionality');
}
$manager = $this->getManager();
$info = $manager->parsePdoDsn($dsn);
$username = $this->getOption('username');
$password = $this->getOption('password');
// Make connection without database specified so we can create it
$connect = $manager->openConnection(new PDO($info['scheme'] . ':host=' . $info['host'], $username, $password), 'tmp_connection', false);
// Create database
$connect->export->createDatabase($info['dbname']);
// Close the tmp connection with no database
$manager->closeConnection($connect);
// Close original connection
$manager->closeConnection($this);
// Reopen original connection with newly created database
$manager->openConnection(new PDO($info['dsn'], $username, $password), $this->getName(), true);
return 'Successfully created database for connection "' . $this->getName() . '" named "' . $info['dbname'] . '"';
} catch (Exception $e) {
return $e;
if ($this->_transactionNestingLevel == 0) {
throw new Doctrine_Exception("Rollback failed. There is no active transaction.");
}
}
$this->connect();
/**
* Method for dropping the database for the connection instance
*
* @return mixed Will return an instance of the exception thrown if the drop
* database fails, otherwise it returns a string detailing the success.
*/
public function dropDatabase()
{
try {
if ( ! $dsn = $this->getOption('dsn')) {
throw new Doctrine_Connection_Exception('You must create your Doctrine_Connection by using a valid Doctrine style dsn in order to use the create/drop database functionality');
}
$info = $this->getManager()->parsePdoDsn($dsn);
$this->export->dropDatabase($info['dbname']);
return 'Successfully dropped database for connection "' . $this->getName() . '" named "' . $info['dbname'] . '"';
} catch (Exception $e) {
return $e;
}
if ($this->_transactionNestingLevel == 1) {
$this->_transactionNestingLevel = 0;
return $this->_pdo->rollback();
}
--$this->_transactionNestingLevel;
return true;
}
/**
@ -1048,19 +846,6 @@ abstract class Doctrine_Connection
protected function _escapePattern($text)
{
return $text;
/*if ( ! $this->string_quoting['escape_pattern']) {
return $text;
}
$tmp = $this->conn->string_quoting;
$text = str_replace($tmp['escape_pattern'],
$tmp['escape_pattern'] .
$tmp['escape_pattern'], $text);
foreach ($this->wildcards as $wildcard) {
$text = str_replace($wildcard, $tmp['escape_pattern'] . $wildcard, $text);
}
return $text;*/
}
/**
@ -1157,4 +942,12 @@ abstract class Doctrine_Connection
}
return $this->_schemaManager;
}
public function getSchemaManager2()
{
if ( ! $this->_schemaManager) {
$this->_schemaManager = $this->_driver->getSchemaManager();
}
return $this->_schemaManager;
}
}

View File

@ -29,7 +29,8 @@
* @since 1.0
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @TODO Remove this class and move the modifyLimitQuery implementation to Connection.
* @TODO Remove this class and move the modifyLimitQuery implementation to Connection.
* @deprecated
*/
class Doctrine_Connection_Common extends Doctrine_Connection
{

View File

@ -28,7 +28,8 @@
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @deprecated
*/
class Doctrine_Connection_Db2 extends Doctrine_Connection
{

View File

@ -18,7 +18,7 @@
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
Doctrine::autoload('Doctrine_Exception');
/**
* Doctrine_Exception
*
@ -28,7 +28,8 @@ Doctrine::autoload('Doctrine_Exception');
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @deprecated
*/
class Doctrine_Connection_Exception extends Doctrine_Exception
{

View File

@ -30,7 +30,8 @@
* @author Lorenzo Alberton <l.alberton@quipo.it> (PEAR MDB2 Interbase driver)
* @version $Revision$
* @link www.phpdoctrine.org
* @since 1.0
* @since 1.0
* @deprecated
*/
class Doctrine_Connection_Firebird extends Doctrine_Connection
{

View File

@ -28,7 +28,8 @@
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @deprecated
*/
class Doctrine_Connection_Informix extends Doctrine_Connection
{

View File

@ -28,7 +28,8 @@
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @deprecated
*/
class Doctrine_Connection_Module
{

View File

@ -29,7 +29,8 @@
* @author Lukas Smith <smith@pooteeweet.org> (PEAR MDB2 library)
* @version $Revision$
* @link www.phpdoctrine.org
* @since 1.0
* @since 1.0
* @deprecated
*/
class Doctrine_Connection_Mssql extends Doctrine_Connection
{

View File

@ -29,7 +29,8 @@
* @author Lukas Smith <smith@pooteeweet.org> (PEAR MDB2 library)
* @version $Revision$
* @link www.phpdoctrine.org
* @since 1.0
* @since 1.0
* @deprecated
*/
class Doctrine_Connection_Mysql extends Doctrine_Connection_Common
{

View File

@ -26,7 +26,8 @@
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @deprecated
*/
class Doctrine_Connection_Oracle extends Doctrine_Connection
{

View File

@ -29,7 +29,8 @@
* @author Lukas Smith <smith@pooteeweet.org> (PEAR MDB2 library)
* @version $Revision$
* @link www.phpdoctrine.org
* @since 1.0
* @since 1.0
* @deprecated
*/
class Doctrine_Connection_Pgsql extends Doctrine_Connection_Common
{

View File

@ -18,7 +18,7 @@
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
Doctrine::autoload('Doctrine_Overloadable');
/**
* Doctrine_Connection_Profiler
*
@ -28,7 +28,9 @@ Doctrine::autoload('Doctrine_Overloadable');
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision$
* @version $Revision$
* @deprecated
* @todo remove
*/
class Doctrine_Connection_Profiler implements Doctrine_Overloadable, IteratorAggregate, Countable
{

View File

@ -18,7 +18,7 @@
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
Doctrine::autoload('Doctrine_Connection_Profiler_Exception');
/**
* Doctrine_Connection_Profiler_Exception
*
@ -28,7 +28,8 @@ Doctrine::autoload('Doctrine_Connection_Profiler_Exception');
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision: 1345 $
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @deprecated
*/
class Doctrine_Connection_Profiler_Exception extends Doctrine_Exception
{

View File

@ -31,7 +31,8 @@
* @author Lukas Smith <smith@pooteeweet.org> (PEAR MDB2 library)
* @version $Revision$
* @link www.phpdoctrine.org
* @since 1.0
* @since 1.0
* @deprecated
*/
class Doctrine_Connection_Sqlite extends Doctrine_Connection_Common
{

View File

@ -18,6 +18,8 @@
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
*/
#namespace Doctrine::DBAL;
/**
* A thin wrapper around PDOStatement.

View File

@ -19,7 +19,7 @@
* <http://www.phpdoctrine.org>.
*/
#namespace Doctrine::ORM::Internal;
#namespace Doctrine::ORM;
#use Doctrine::ORM::Entity;
#use Doctrine::ORM::EntityManager;
@ -36,7 +36,7 @@
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Roman Borschel <roman@code-factory.org>
* @todo Rename: Doctrine::ORM::(Internal::)UnitOfWork.
* @todo Rename: Doctrine::ORM::UnitOfWork.
* @todo Turn connection exceptions into UnitOfWorkExceptions.
*/
class Doctrine_Connection_UnitOfWork

View File

@ -0,0 +1,36 @@
<?php
/**
* Connection interface.
* Drivers must implement this interface.
*
* This includes the full PDO interface as well as custom extensions of
* Doctrine's DBAL.
*
* @since 2.0
*/
interface Doctrine_DBAL_Connection
{
const TRANSACTION_READ_UNCOMMITTED = 1;
const TRANSACTION_READ_COMMITTED = 2;
const TRANSACTION_REPEATABLE_READ = 3;
const TRANSACTION_SERIALIZABLE = 4;
/* PDO 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();
/* Doctrine DBAL extensions */
public function setTransactionIsolation($level);
public function getTransactionIsolation();
}
?>

View File

@ -0,0 +1,38 @@
<?php
/**
* Driver interface.
* Interface that all DBAL drivers must implement.
*
* @since 2.0
*/
interface Doctrine_DBAL_Driver
{
/**
* Attempts to create a connection with the database.
*
* @param array $params All connection parameters passed by the user.
* @param string $username The username to use when connecting.
* @param string $password The password to use when connecting.
* @param array $driverOptions The driver options to use when connecting.
* @return Doctrine::DBAL::Connection The database connection.
*/
public function connect(array $params, $username = null, $password = null, array $driverOptions = array());
/**
* Gets the DatabasePlatform instance that provides all the metadata about
* the platform this driver connects to.
*
* @return Doctrine::DBAL::DatabasePlatform The database platform.
*/
public function getDatabasePlatform();
/**
* Gets the SchemaManager that can be used to inspect and change the underlying
* database schema of the platform this driver connects to.
*
* @return Doctrine::DBAL::SchemaManager
*/
public function getSchemaManager();
}
?>

View File

@ -0,0 +1,89 @@
<?php
#namespace Doctrine::DBAL::Driver::PDOMsSql;
/**
* MsSql Connection implementation.
*
* @since 2.0
*/
class Doctrine_DBAL_Driver_PDOMsSql_Connection extends PDO implements Doctrine_DBAL_Connection
{
private $_isolationLevel = Doctrine_DBAL_Connection::TRANSACTION_READ_COMMITTED;
/**
* Set the transacton isolation level.
*
* @param string standard isolation level (SQL-92)
* portable modes:
* READ UNCOMMITTED (allows dirty reads)
* READ COMMITTED (prevents dirty reads)
* REPEATABLE READ (prevents nonrepeatable reads)
* SERIALIZABLE (prevents phantom reads)
*
* @link http://msdn2.microsoft.com/en-us/library/ms173763.aspx
* @throws PDOException if something fails at the PDO level
* @throws Doctrine_Transaction_Exception if using unknown isolation level or unknown wait option
* @return void
* @override
*/
public function setTransactionIsolation($level, $options = array()) {
$sql = "";
switch ($level) {
case Doctrine_DBAL_Connection::TRANSACTION_READ_UNCOMMITTED:
$sql = 'READ UNCOMMITTED';
break;
case Doctrine_DBAL_Connection::TRANSACTION_READ_COMMITTED:
$sql = 'READ COMMITTED';
break;
case Doctrine_DBAL_Connection::TRANSACTION_REPEATABLE_READ:
$sql = 'REPEATABLE READ';
break;
case Doctrine_DBAL_Connection::TRANSACTION_SERIALIZABLE:
$sql = 'SERIALIZABLE';
break;
default:
throw new Doctrine_Transaction_Exception('isolation level is not supported: ' . $isolation);
}
$this->_isolationLevel = $level;
$this->exec('SET TRANSACTION ISOLATION LEVEL ' . $sql);
}
public function getTransactionIsolation()
{
return $this->_isolationLevel;
}
/**
* Performs the rollback.
*
* @override
*/
public function rollback()
{
$this->exec('ROLLBACK TRANSACTION');
}
/**
* Performs the commit.
*
* @override
*/
public function commit()
{
$this->exec('COMMIT TRANSACTION');
}
/**
* Begins a database transaction.
*
* @override
*/
public function beginTransaction()
{
$this->exec('BEGIN TRANSACTION');
}
}
?>

View File

@ -0,0 +1,39 @@
<?php
#namespace Doctrine::DBAL::Driver::PDOMySql;
#use Doctrine::DBAL::Driver;
class Doctrine_DBAL_Driver_PDOMsSql_Driver implements Doctrine_DBAL_Driver
{
public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
{
return new PDO($this->_constructPdoDsn($params), $username, $password, $driverOptions);
}
/**
* Constructs the MySql PDO DSN.
*
* Overrides Connection#_constructPdoDsn().
*
* @return string The DSN.
*/
private function _constructPdoDsn(array $params)
{
//TODO
}
public function getDatabasePlatform()
{
return new Doctrine_DatabasePlatform_MySqlPlatform();
}
public function getSchemaManager(Doctrine_Connection $conn)
{
return new Doctrine_Schema_MySqlSchemaManager($conn);
}
}
?>

View File

@ -0,0 +1,57 @@
<?php
class Doctrine_DBAL_Driver_PDOMySql_Connection extends PDO implements Doctrine_DBAL_Connection
{
private $_isolationLevel = Doctrine_DBAL_Connection::TRANSACTION_READ_COMMITTED;
/**
* Set the transacton isolation level.
*
* @param string standard isolation level
* READ UNCOMMITTED (allows dirty reads)
* READ COMMITTED (prevents dirty reads)
* REPEATABLE READ (prevents nonrepeatable reads)
* SERIALIZABLE (prevents phantom reads)
*
* @throws Doctrine_Transaction_Exception if using unknown isolation level
* @throws PDOException if something fails at the PDO level
* @return void
*/
public function setTransactionIsolation($level)
{
$sql = "";
switch ($level) {
case Doctrine_DBAL_Connection::TRANSACTION_READ_UNCOMMITTED:
$sql = 'READ UNCOMMITTED';
break;
case Doctrine_DBAL_Connection::TRANSACTION_READ_COMMITTED:
$sql = 'READ COMMITTED';
break;
case Doctrine_DBAL_Connection::TRANSACTION_REPEATABLE_READ:
$sql = 'REPEATABLE READ';
break;
case Doctrine_DBAL_Connection::TRANSACTION_SERIALIZABLE:
$sql = 'SERIALIZABLE';
break;
default:
throw new Doctrine_Transaction_Exception('isolation level is not supported: ' . $isolation);
}
$this->_isolationLevel = $level;
return $this->exec('SET SESSION TRANSACTION ISOLATION LEVEL ' . $sql);
}
/**
* getTransactionIsolation
*
* @return string returns the current session transaction isolation level
*/
public function getTransactionIsolation()
{
return $this->_isolationLevel;
}
}
?>

View File

@ -0,0 +1,53 @@
<?php
#namespace Doctrine::DBAL::Driver::PDOMySql;
#use Doctrine::DBAL::Driver;
class Doctrine_DBAL_Driver_PDOMySql_Driver implements Doctrine_DBAL_Driver
{
public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
{
return new PDO($this->_constructPdoDsn($params), $username, $password, $driverOptions);
}
/**
* Constructs the MySql PDO DSN.
*
* Overrides Connection#_constructPdoDsn().
*
* @return string The DSN.
*/
private function _constructPdoDsn(array $params)
{
$dsn = 'mysql:';
if (isset($params['host'])) {
$dsn .= 'host=' . $params['host'] . ';';
}
if (isset($params['port'])) {
$dsn .= 'port=' . $params['port'] . ';';
}
if (isset($params['dbname'])) {
$dsn .= 'dbname=' . $params['dbname'] . ';';
}
if (isset($params['unix_socket'])) {
$dsn .= 'unix_socket=' . $params['unix_socket'] . ';';
}
return $dsn;
}
public function getDatabasePlatform()
{
return new Doctrine_DatabasePlatform_MySqlPlatform();
}
public function getSchemaManager(Doctrine_Connection $conn)
{
return new Doctrine_Schema_MySqlSchemaManager($conn);
}
}
?>

View File

@ -0,0 +1,37 @@
<?php
#namespace Doctrine::DBAL::Driver::PDOOracle;
#use Doctrine::DBAL::Driver;
class Doctrine_DBAL_Driver_PDOOracle_Driver implements Doctrine_DBAL_Driver
{
public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
{
return new PDO($this->_constructPdoDsn($params), $username, $password, $driverOptions);
}
/**
* Constructs the Oracle PDO DSN.
*
* @return string The DSN.
*/
private function _constructPdoDsn(array $params)
{
//TODO
}
public function getDatabasePlatform()
{
return new Doctrine_DatabasePlatform_OraclePlatform();
}
public function getSchemaManager(Doctrine_Connection $conn)
{
return new Doctrine_Schema_OracleSchemaManager($conn);
}
}
?>

View File

@ -0,0 +1,40 @@
<?php
#namespace Doctrine::DBAL::Driver::PDOPgSql;
/**
* Driver that connects through pdo_pgsql.
*
* @since 2.0
*/
class Doctrine_DBAL_Driver_PDOPgSql_Driver implements Doctrine_DBAL_Driver
{
public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
{
return new PDO($this->_constructPdoDsn($params), $username, $password, $driverOptions);
}
/**
* Constructs the Postgres PDO DSN.
*
* @return string The DSN.
*/
private function _constructPdoDsn(array $params)
{
//TODO
}
public function getDatabasePlatform()
{
return new Doctrine_DatabasePlatform_PostgreSqlPlatform();
}
public function getSchemaManager(Doctrine_Connection $conn)
{
return new Doctrine_Schema_PostgreSqlSchemaManager($conn);
}
}
?>

View File

@ -0,0 +1,45 @@
<?php
#namespace Doctrine::DBAL::Driver::PDOOracle;
#use Doctrine::DBAL::Driver;
class Doctrine_DBAL_Driver_PDOSqlite_Driver implements Doctrine_DBAL_Driver
{
public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
{
return new PDO($this->_constructPdoDsn($params), $username, $password, $driverOptions);
}
/**
* Constructs the Sqlite PDO DSN.
*
* @return string The DSN.
* @override
*/
protected function _constructPdoDsn(array $params)
{
$dsn = 'sqlite:';
if (isset($params['path'])) {
$dsn .= $params['path'];
} else if (isset($params['memory'])) {
$dsn .= ':memory:';
}
return $dsn;
}
public function getDatabasePlatform()
{
return new Doctrine_DatabasePlatform_SqlitePlatform();
}
public function getSchemaManager(Doctrine_Connection $conn)
{
return new Doctrine_Schema_SqliteSchemaManager($conn);
}
}
?>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,15 @@
<?php
#namespace Doctrine::DBAL::Platforms;
class Doctrine_DBAL_Platforms_Db2Platform extends Doctrine_DBAL_Platforms_AbstractPlatform
{
public function getSequenceNextValSql($sequenceName) {
return 'SELECT NEXTVAL FOR ' . $this->quoteIdentifier($sequenceName)
. ' FROM SYSIBM.SYSDUMMY1';
}
}
?>

View File

@ -7,7 +7,7 @@
*
* @since 2.0
*/
class Doctrine_DatabasePlatform_FirebirdPlatform extends Doctrine_DatabasePlatform
class Doctrine_DBAL_Platforms_FirebirdPlatform extends Doctrine_DBAL_Platforms_AbstractPlatform
{
/**

View File

@ -7,7 +7,7 @@
*
* @since 2.0
*/
class Doctrine_DatabasePlatform_InformixPlatform extends Doctrine_DatabasePlatform
class Doctrine_DBAL_Platforms_InformixPlatform extends Doctrine_DBAL_Platforms_AbstractPlatform
{
public function __construct()

View File

@ -1,6 +1,7 @@
<?php
#namespace Doctrine::DBAL::Platforms;
class Doctrine_DatabasePlatform_MockPlatform extends Doctrine_DatabasePlatform
class Doctrine_DBAL_Platforms_MockPlatform extends Doctrine_DBAL_Platforms_AbstractPlatform
{
public function getNativeDeclaration(array $field) {}
public function getPortableDeclaration(array $field) {}

View File

@ -1,6 +1,8 @@
<?php
class Doctrine_DatabasePlatform_MsSqlPlatform extends Doctrine_DatabasePlatform
#namespace Doctrine::DBAL::Platforms;
class Doctrine_DBAL_Platforms_MsSqlPlatform extends Doctrine_DBAL_Platforms_AbstractPlatform
{
/**
* the constructor
@ -279,6 +281,36 @@ class Doctrine_DatabasePlatform_MsSqlPlatform extends Doctrine_DatabasePlatform
'fixed' => $fixed);
}
/**
* Quote a string so it can be safely used as a table / column name
*
* Quoting style depends on which database driver is being used.
*
* @param string $identifier identifier name to be quoted
* @param bool $checkOption check the 'quote_identifier' option
*
* @return string quoted identifier string
* @override
*/
public function quoteIdentifier($identifier, $checkOption = false)
{
if ($checkOption && ! $this->getAttribute(Doctrine::ATTR_QUOTE_IDENTIFIER)) {
return $identifier;
}
if (strpos($identifier, '.') !== false) {
$parts = explode('.', $identifier);
$quotedParts = array();
foreach ($parts as $p) {
$quotedParts[] = $this->quoteIdentifier($p);
}
return implode('.', $quotedParts);
}
return '[' . str_replace(']', ']]', $identifier) . ']';
}
}
?>

View File

@ -19,6 +19,8 @@
* <http://www.phpdoctrine.org>.
*/
#namespace Doctrine::DBAL::Platforms;
/**
* The MySqlPlatform provides the behavior, features and SQL dialect of the
* MySQL database platform.
@ -26,7 +28,7 @@
* @since 2.0
* @author Roman Borschel <roman@code-factory.org>
*/
class Doctrine_DatabasePlatform_MySqlPlatform extends Doctrine_DatabasePlatform
class Doctrine_DBAL_Platforms_MySqlPlatform extends Doctrine_DBAL_Platforms_AbstractPlatform
{
/**
* MySql reserved words.

View File

@ -19,6 +19,8 @@
* <http://www.phpdoctrine.org>.
*/
#namespace Doctrine::DBAL::Platforms;
/**
* Base class for all DatabasePlatforms. The DatabasePlatforms are the central
* point of abstraction of platform-specific behaviors, features and SQL dialects.
@ -28,7 +30,7 @@
* @author Roman Borschel <roman@code-factory.org>
* @author Lukas Smith <smith@pooteeweet.org> (PEAR MDB2 library)
*/
class Doctrine_DatabasePlatform_OraclePlatform extends Doctrine_DatabasePlatform
class Doctrine_DBAL_Platforms_OraclePlatform extends Doctrine_DBAL_Platforms_AbstractPlatform
{
/**
* Constructor.

View File

@ -1,7 +1,8 @@
<?php
#namespace Doctrine::DBAL::Platforms;
class Doctrine_DatabasePlatform_PostgreSqlPlatform extends Doctrine_DatabasePlatform
class Doctrine_DBAL_Platforms_PostgreSqlPlatform extends Doctrine_DBAL_Platforms_AbstractPlatform
{
/**
* The reserved keywords by pgsql. Ordered alphabetically.

View File

@ -7,7 +7,7 @@
*
* @since 2.0
*/
class Doctrine_DatabasePlatform_SqlitePlatform extends Doctrine_DatabasePlatform
class Doctrine_DBAL_Platforms_SqlitePlatform extends Doctrine_DBAL_Platforms_AbstractPlatform
{
/**

View File

@ -0,0 +1,297 @@
<?php
/*
* $Id: Interface.php 3882 2008-02-22 18:11:35Z jwage $
*
* 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;
/**
* Statement interface.
* Drivers must implement this interface.
*
* This includes the full PDOStatement interface as well as custom extensions of
* Doctrine's DBAL.
*
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Roman Borschel <roman@code-factory.org>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision$
*/
interface Doctrine_DBAL_Statement
{
/**
* 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);
}

View File

@ -5,7 +5,7 @@
*
* @since 2.0
*/
class Doctrine_DataType_ArrayType extends Doctrine_DataType
class Doctrine_DBAL_Types_ArrayType extends Doctrine_DBAL_Types_Type
{

View File

@ -4,7 +4,7 @@
* Type that maps an SQL boolean to a PHP boolean.
*
*/
class Doctrine_DataType_BooleanType extends Doctrine_DataType
class Doctrine_DBAL_Types_BooleanType extends Doctrine_DBAL_Types_Type
{
/**
* Enter description here...

View File

@ -5,7 +5,7 @@
*
* @since 2.0
*/
class Doctrine_DataType_DateTimeType extends Doctrine_DataType
class Doctrine_DBAL_Types_DateTimeType extends Doctrine_DBAL_Types_Type
{
/**
* Enter description here...

View File

@ -4,7 +4,7 @@
* Type that maps an SQL DECIMAL to a PHP double.
*
*/
class Doctrine_DataType_DecimalType extends Doctrine_DataType
class Doctrine_DBAL_Types_DecimalType extends Doctrine_DBAL_Types_Type
{
}

View File

@ -4,7 +4,7 @@
* Type that maps an SQL INT/MEDIUMINT/BIGINT to a PHP integer.
*
*/
class Doctrine_DataType_IntegerType extends Doctrine_DataType
class Doctrine_DBAL_Types_IntegerType extends Doctrine_DBAL_Types_Type
{

View File

@ -7,7 +7,7 @@
*
* @since 2.0
*/
class Doctrine_DataType_StringType extends Doctrine_DataType
class Doctrine_DBAL_Types_StringType extends Doctrine_DBAL_Types_Type
{
public function getSqlDeclaration(array $fieldDeclaration, Doctrine_DatabasePlatform $platform)
{

View File

@ -5,7 +5,7 @@
*
* @since 2.0
*/
class Doctrine_DataType_TextType extends Doctrine_DataType
class Doctrine_DBAL_Types_TextType extends Doctrine_DBAL_Types_Type
{
/**
* Enter description here...

View File

@ -1762,6 +1762,18 @@ abstract class Doctrine_DatabasePlatform
}
return $item;
}
/**
* Enter description here...
*
* @param unknown_type $charset
* @return string
*/
public function getSetCharsetSql($charset)
{
return 'SET NAMES ' . $this->quote($charset);
}
/* supports*() metods */

View File

@ -19,6 +19,8 @@
* <http://www.phpdoctrine.org>.
*/
#namespace Doctrine::ORM::Internal;
/**
* Defines an array hydration strategy.
*

View File

@ -31,16 +31,7 @@
* @since 2.0
*/
class Doctrine_Schema_MySqlSchemaManager extends Doctrine_Schema_SchemaManager
{
/*protected $_sql = array(
'showDatabases' => 'SHOW DATABASES',
'listTableFields' => 'DESCRIBE %s',
'listSequences' => 'SHOW TABLES',
'listTables' => 'SHOW TABLES',
'listUsers' => 'SELECT DISTINCT USER FROM USER',
'listViews' => "SHOW FULL TABLES %s WHERE Table_type = 'VIEW'",
);*/
{
public function __construct(Doctrine_Connection $conn)
{
$this->_conn = $conn;

View File

@ -30,7 +30,8 @@
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision$
* @version $Revision$
* @deprecated
*/
class Doctrine_Transaction extends Doctrine_Connection_Module
{
@ -110,29 +111,17 @@ class Doctrine_Transaction extends Doctrine_Connection_Module
public function begin($savepoint = null)
{
$this->conn->connect();
//$listener = $this->conn->getAttribute(Doctrine::ATTR_LISTENER);
if ( ! is_null($savepoint)) {
$this->savePoints[] = $savepoint;
//$event = new Doctrine_Event($this, Doctrine_Event::SAVEPOINT_CREATE);
//$listener->preSavepointCreate($event);
//if ( ! $event->skipOperation) {
$this->createSavePoint($savepoint);
//}
//$listener->postSavepointCreate($event);
$this->createSavePoint($savepoint);
} else {
if ($this->_nestingLevel == 0) {
//$event = new Doctrine_Event($this, Doctrine_Event::TX_BEGIN);
//$listener->preTransactionBegin($event);
//if ( ! $event->skipOperation) {
try {
$this->_doBeginTransaction();
} catch (Exception $e) {
throw new Doctrine_Transaction_Exception($e->getMessage());
}
//}
//$listener->postTransactionBegin($event);
try {
$this->_doBeginTransaction();
} catch (Exception $e) {
throw new Doctrine_Transaction_Exception($e->getMessage());
}
}
}
@ -161,24 +150,12 @@ class Doctrine_Transaction extends Doctrine_Connection_Module
$this->conn->connect();
//$listener = $this->conn->getAttribute(Doctrine::ATTR_LISTENER);
if ( ! is_null($savepoint)) {
$this->_nestingLevel -= $this->removeSavePoints($savepoint);
//$event = new Doctrine_Event($this, Doctrine_Event::SAVEPOINT_COMMIT);
//$listener->preSavepointCommit($event);
//if ( ! $event->skipOperation) {
$this->releaseSavePoint($savepoint);
//}
//$listener->postSavepointCommit($event);
$this->releaseSavePoint($savepoint);
} else {
if ($this->_nestingLevel == 1) {
//$event = new Doctrine_Event($this, Doctrine_Event::TX_COMMIT);
//$listener->preTransactionCommit($event);
//if ( ! $event->skipOperation) {
$this->_doCommit();
//}
//$listener->postTransactionCommit($event);
$this->_doCommit();
}
if ($this->_nestingLevel > 0) {
@ -219,24 +196,14 @@ class Doctrine_Transaction extends Doctrine_Connection_Module
if ( ! is_null($savepoint)) {
$this->_nestingLevel -= $this->removeSavePoints($savepoint);
//$event = new Doctrine_Event($this, Doctrine_Event::SAVEPOINT_ROLLBACK);
//$listener->preSavepointRollback($event);
//if ( ! $event->skipOperation) {
$this->rollbackSavePoint($savepoint);
//}
//$listener->postSavepointRollback($event);
$this->rollbackSavePoint($savepoint);
} else {
//$event = new Doctrine_Event($this, Doctrine_Event::TX_ROLLBACK);
//$listener->preTransactionRollback($event);
//if ( ! $event->skipOperation) {
$this->_nestingLevel = 0;
try {
$this->_doRollback();
} catch (Exception $e) {
throw new Doctrine_Transaction_Exception($e->getMessage());
}
//}
//$listener->postTransactionRollback($event);
$this->_nestingLevel = 0;
try {
$this->_doRollback();
} catch (Exception $e) {
throw new Doctrine_Transaction_Exception($e->getMessage());
}
}
return true;

View File

@ -28,7 +28,8 @@ Doctrine::autoload('Doctrine_Exception');
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @since 1.0
* @version $Revision$
* @link www.phpdoctrine.org
* @link www.phpdoctrine.org
* @todo remove
*/
class Doctrine_Transaction_Exception extends Doctrine_Exception
{ }

View File

@ -28,7 +28,8 @@
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision$
* @version $Revision$
* @todo remove
*/
class Doctrine_Transaction_Firebird extends Doctrine_Transaction
{

View File

@ -26,7 +26,8 @@
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision$
* @version $Revision$
* @todo remove
*/
class Doctrine_Transaction_Informix extends Doctrine_Transaction
{ }

View File

@ -30,7 +30,8 @@ Doctrine::autoload('Doctrine_Transaction');
* @subpackage Transaction
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision$
* @version $Revision$
* @todo remove
*/
class Doctrine_Transaction_Mock extends Doctrine_Transaction
{ }

View File

@ -28,7 +28,8 @@
* @subpackage Transaction
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision$
* @version $Revision$
* @todo remove
*/
class Doctrine_Transaction_Mssql extends Doctrine_Transaction
{

View File

@ -28,7 +28,8 @@
* @subpackage Transaction
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision$
* @version $Revision$
* @todo remove
*/
class Doctrine_Transaction_Mysql extends Doctrine_Transaction
{

View File

@ -28,7 +28,8 @@
* @subpackage Transaction
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision$
* @version $Revision$
* @todo remove
*/
class Doctrine_Transaction_Oracle extends Doctrine_Transaction
{

View File

@ -29,7 +29,8 @@
* @subpackage Transaction
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision$
* @version $Revision$
* @todo remove
*/
class Doctrine_Transaction_Pgsql extends Doctrine_Transaction
{

View File

@ -28,7 +28,8 @@
* @subpackage Transaction
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision$
* @version $Revision$
* @todo remove
*/
class Doctrine_Transaction_Sqlite extends Doctrine_Transaction
{