Commit 270cd8b4 authored by Benjamin Eberlei's avatar Benjamin Eberlei

Merge pull request #243 from BenMorel/master

Documentation fixes
parents 4804a9a0 f0eaaf6f
......@@ -24,11 +24,29 @@ use PDO;
class ArrayStatement implements \IteratorAggregate, ResultStatement
{
/**
* @var array
*/
private $data;
/**
* @var integer
*/
private $columnCount = 0;
/**
* @var integer
*/
private $num = 0;
/**
* @var integer
*/
private $defaultFetchMode = PDO::FETCH_BOTH;
/**
* @param array $data
*/
public function __construct(array $data)
{
$this->data = $data;
......@@ -37,16 +55,25 @@ class ArrayStatement implements \IteratorAggregate, ResultStatement
}
}
/**
* {@inheritdoc}
*/
public function closeCursor()
{
unset ($this->data);
}
/**
* {@inheritdoc}
*/
public function columnCount()
{
return $this->columnCount;
}
/**
* {@inheritdoc}
*/
public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null)
{
if ($arg2 !== null || $arg3 !== null) {
......@@ -54,14 +81,23 @@ class ArrayStatement implements \IteratorAggregate, ResultStatement
}
$this->defaultFetchMode = $fetchMode;
return true;
}
/**
* {@inheritdoc}
*/
public function getIterator()
{
$data = $this->fetchAll();
return new \ArrayIterator($data);
}
/**
* {@inheritdoc}
*/
public function fetch($fetchMode = null)
{
if (isset($this->data[$this->num])) {
......@@ -79,18 +115,26 @@ class ArrayStatement implements \IteratorAggregate, ResultStatement
throw new \InvalidArgumentException("Invalid fetch-style given for fetching result.");
}
}
return false;
}
/**
* {@inheritdoc}
*/
public function fetchAll($fetchMode = null)
{
$rows = array();
while ($row = $this->fetch($fetchMode)) {
$rows[] = $row;
}
return $rows;
}
/**
* {@inheritdoc}
*/
public function fetchColumn($columnIndex = 0)
{
$row = $this->fetch(PDO::FETCH_NUM);
......@@ -98,6 +142,7 @@ class ArrayStatement implements \IteratorAggregate, ResultStatement
// TODO: verify this is correct behavior
return false;
}
return $row[$columnIndex];
}
}
......@@ -25,11 +25,17 @@ namespace Doctrine\DBAL\Cache;
*/
class CacheException extends \Doctrine\DBAL\DBALException
{
/**
* @return \Doctrine\DBAL\Cache\CacheException
*/
static public function noCacheKey()
{
return new self("No cache key was set.");
}
/**
* @return \Doctrine\DBAL\Cache\CacheException
*/
static public function noResultDriverConfigured()
{
return new self("Trying to cache a query but no result driver is configured.");
......
......@@ -31,22 +31,24 @@ use Doctrine\Common\Cache\Cache;
class QueryCacheProfile
{
/**
* @var Cache
* @var \Doctrine\Common\Cache\Cache|null
*/
private $resultCacheDriver;
/**
* @var int
* @var integer
*/
private $lifetime = 0;
/**
* @var string
* @var string|null
*/
private $cacheKey;
/**
* @param int $lifetime
* @param string $cacheKey
* @param Cache $resultCache
* @param integer $lifetime
* @param string|null $cacheKey
* @param \Doctrine\Common\Cache\Cache|null $resultCache
*/
public function __construct($lifetime = 0, $cacheKey = null, Cache $resultCache = null)
{
......@@ -56,7 +58,7 @@ class QueryCacheProfile
}
/**
* @return Cache
* @return \Doctrine\Common\Cache\Cache|null
*/
public function getResultCacheDriver()
{
......@@ -64,7 +66,7 @@ class QueryCacheProfile
}
/**
* @return int
* @return integer
*/
public function getLifetime()
{
......@@ -73,21 +75,25 @@ class QueryCacheProfile
/**
* @return string
*
* @throws \Doctrine\DBAL\Cache\CacheException
*/
public function getCacheKey()
{
if ($this->cacheKey === null) {
throw CacheException::noCacheKey();
}
return $this->cacheKey;
}
/**
* Generate the real cache key from query, params and types.
* Generates the real cache key from query, params and types.
*
* @param string $query
* @param array $params
* @param array $types
* @param array $params
* @param array $types
*
* @return array
*/
public function generateCacheKeys($query, $params, $types)
......@@ -99,12 +105,14 @@ class QueryCacheProfile
} else {
$cacheKey = $this->cacheKey;
}
return array($cacheKey, $realCacheKey);
}
/**
* @param Cache $cache
* @return QueryCacheProfile
* @param \Doctrine\Common\Cache\Cache $cache
*
* @return \Doctrine\DBAL\Cache\QueryCacheProfile
*/
public function setResultCacheDriver(Cache $cache)
{
......@@ -113,7 +121,8 @@ class QueryCacheProfile
/**
* @param string|null $cacheKey
* @return QueryCacheProfile
*
* @return \Doctrine\DBAL\Cache\QueryCacheProfile
*/
public function setCacheKey($cacheKey)
{
......@@ -121,8 +130,9 @@ class QueryCacheProfile
}
/**
* @param int $lifetime
* @return QueryCacheProfile
* @param integer $lifetime
*
* @return \Doctrine\DBAL\Cache\QueryCacheProfile
*/
public function setLifetime($lifetime)
{
......
......@@ -21,7 +21,6 @@ namespace Doctrine\DBAL\Cache;
use Doctrine\DBAL\Driver\Statement;
use Doctrine\DBAL\Driver\ResultStatement;
use Doctrine\DBAL\Connection;
use Doctrine\Common\Cache\Cache;
use PDO;
......@@ -57,7 +56,7 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement
private $realKey;
/**
* @var int
* @var integer
*/
private $lifetime;
......@@ -69,7 +68,7 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement
/**
* Did we reach the end of the statement?
*
* @var bool
* @var boolean
*/
private $emptied = false;
......@@ -79,16 +78,16 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement
private $data;
/**
* @var int
* @var integer
*/
private $defaultFetchMode = PDO::FETCH_BOTH;
/**
* @param Statement $stmt
* @param Cache $resultCache
* @param string $cacheKey
* @param string $realKey
* @param int $lifetime
* @param \Doctrine\DBAL\Driver\Statement $stmt
* @param \Doctrine\Common\Cache\Cache $resultCache
* @param string $cacheKey
* @param string $realKey
* @param integer $lifetime
*/
public function __construct(Statement $stmt, Cache $resultCache, $cacheKey, $realKey, $lifetime)
{
......@@ -100,9 +99,7 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement
}
/**
* Closes the cursor, enabling the statement to be executed again.
*
* @return boolean Returns TRUE on success or FALSE on failure.
* {@inheritdoc}
*/
public function closeCursor()
{
......@@ -120,38 +117,35 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement
}
/**
* columnCount
* Returns the number of columns in the result set
*
* @return integer Returns the number of columns in the result set represented
* by the PDOStatement object. If there is no result set,
* this method should return 0.
* {@inheritdoc}
*/
public function columnCount()
{
return $this->statement->columnCount();
}
/**
* {@inheritdoc}
*/
public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null)
{
$this->defaultFetchMode = $fetchMode;
return true;
}
/**
* {@inheritdoc}
*/
public function getIterator()
{
$data = $this->fetchAll();
return new \ArrayIterator($data);
}
/**
* fetch
*
* @see Query::HYDRATE_* constants
* @param integer $fetchMode Controls how the next row will be returned to the caller.
* This value must be one of the Query::HYDRATE_* constants,
* defaulting to Query::HYDRATE_BOTH
*
* @return mixed
* {@inheritdoc}
*/
public function fetch($fetchMode = null)
{
......@@ -178,17 +172,12 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement
}
}
$this->emptied = true;
return false;
}
/**
* Returns an array containing all of the result set rows
*
* @param integer $fetchMode Controls how the next row will be returned to the caller.
* This value must be one of the Query::HYDRATE_* constants,
* defaulting to Query::HYDRATE_BOTH
*
* @return array
* {@inheritdoc}
*/
public function fetchAll($fetchMode = null)
{
......@@ -196,19 +185,12 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement
while ($row = $this->fetch($fetchMode)) {
$rows[] = $row;
}
return $rows;
}
/**
* 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, PDOStatement->fetchColumn()
* fetches the first column.
*
* @return string returns a single column in the next row of a result set.
* {@inheritdoc}
*/
public function fetchColumn($columnIndex = 0)
{
......@@ -217,12 +199,12 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement
// TODO: verify this is correct behavior
return false;
}
return $row[$columnIndex];
}
/**
* rowCount
* rowCount() returns the number of rows affected by the last DELETE, INSERT, or UPDATE statement
* 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,
......@@ -230,7 +212,7 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement
* this behaviour is not guaranteed for all databases and should not be
* relied on for portable applications.
*
* @return integer Returns the number of rows.
* @return integer The number of rows.
*/
public function rowCount()
{
......
......@@ -25,10 +25,10 @@ use Doctrine\Common\Cache\Cache;
/**
* Configuration container for the Doctrine DBAL.
*
* @since 2.0
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
* @since 2.0
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
* @internal When adding a new configuration option just write a getter/setter
* pair and add the option to the _attributes array with a proper default value.
*/
......@@ -45,7 +45,9 @@ class Configuration
/**
* Sets the SQL logger to use. Defaults to NULL which means SQL logging is disabled.
*
* @param SQLLogger $logger
* @param \Doctrine\DBAL\Logging\SQLLogger|null $logger
*
* @return void
*/
public function setSQLLogger(SQLLogger $logger = null)
{
......@@ -55,7 +57,7 @@ class Configuration
/**
* Gets the SQL logger that is used.
*
* @return SQLLogger
* @return \Doctrine\DBAL\Logging\SQLLogger
*/
public function getSQLLogger()
{
......@@ -66,7 +68,7 @@ class Configuration
/**
* Gets the cache driver implementation that is used for query result caching.
*
* @return \Doctrine\Common\Cache\Cache
* @return \Doctrine\Common\Cache\Cache|null
*/
public function getResultCacheImpl()
{
......@@ -78,6 +80,8 @@ class Configuration
* Sets the cache driver implementation that is used for query result caching.
*
* @param \Doctrine\Common\Cache\Cache $cacheImpl
*
* @return void
*/
public function setResultCacheImpl(Cache $cacheImpl)
{
......@@ -85,13 +89,15 @@ class Configuration
}
/**
* Filter schema assets expression.
* Sets the filter schema assets expression.
*
* Only include tables/sequences matching the filter expression regexp in
* schema instances generated for the active connection when calling
* {AbstractSchemaManager#createSchema()}.
*
* @param string $filterExpression
*
* @return void
*/
public function setFilterSchemaAssetsExpression($filterExpression)
{
......@@ -99,7 +105,7 @@ class Configuration
}
/**
* Return filter schema assets expression.
* Returns filter schema assets expression.
*
* @return string|null
*/
......@@ -108,6 +114,7 @@ class Configuration
if (isset($this->_attributes['filterSchemaAssetsExpression'])) {
return $this->_attributes['filterSchemaAssetsExpression'];
}
return null;
}
}
This diff is collapsed.
<?php
/*
* $Id: Exception.php 4628 2008-07-04 16:32:19Z romanb $
*
* 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
......@@ -22,31 +20,39 @@
namespace Doctrine\DBAL;
/**
* Doctrine\DBAL\ConnectionException
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision: 4628 $
* @author Jonathan H. Wage <jonwage@gmail.com
* @link www.doctrine-project.org
* @since 2.0
* @author Jonathan H. Wage <jonwage@gmail.com
*/
class ConnectionException extends DBALException
{
/**
* @return \Doctrine\DBAL\ConnectionException
*/
public static function commitFailedRollbackOnly()
{
return new self("Transaction commit failed because the transaction has been marked for rollback only.");
}
/**
* @return \Doctrine\DBAL\ConnectionException
*/
public static function noActiveTransaction()
{
return new self("There is no active transaction.");
}
/**
* @return \Doctrine\DBAL\ConnectionException
*/
public static function savepointsNotSupported()
{
return new self("Savepoints are not supported by this driver.");
}
/**
* @return \Doctrine\DBAL\ConnectionException
*/
public static function mayNotAlterNestedTransactionWithSavepointsInTransaction()
{
return new self("May not alter the nested transaction with savepoints behavior while a transaction is open.");
......
......@@ -19,13 +19,12 @@
namespace Doctrine\DBAL\Connections;
use Doctrine\DBAL\Connection,
Doctrine\DBAL\Driver,
Doctrine\DBAL\Configuration,
Doctrine\Common\EventManager,
Doctrine\DBAL\Event\ConnectionEventArgs,
Doctrine\DBAL\Events;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Configuration;
use Doctrine\Common\EventManager;
use Doctrine\DBAL\Event\ConnectionEventArgs;
use Doctrine\DBAL\Events;
/**
* Master-Slave Connection
......@@ -84,7 +83,7 @@ use Doctrine\DBAL\Connection,
class MasterSlaveConnection extends Connection
{
/**
* Master and slave connection (one of the randomly picked slaves)
* Master and slave connection (one of the randomly picked slaves).
*
* @var \Doctrine\DBAL\Driver\Connection[]
*/
......@@ -94,17 +93,19 @@ class MasterSlaveConnection extends Connection
* You can keep the slave connection and then switch back to it
* during the request if you know what you are doing.
*
* @var bool
* @var boolean
*/
protected $keepSlave = false;
/**
* Create Master Slave Connection
* Creates Master Slave Connection.
*
* @param array $params
* @param \Doctrine\DBAL\Driver $driver
* @param \Doctrine\DBAL\Configuration|null $config
* @param \Doctrine\Common\EventManager|null $eventManager
*
* @param array $params
* @param Driver $driver
* @param Configuration $config
* @param EventManager $eventManager
* @throws \InvalidArgumentException
*/
public function __construct(array $params, Driver $driver, Configuration $config = null, EventManager $eventManager = null)
{
......@@ -126,9 +127,9 @@ class MasterSlaveConnection extends Connection
}
/**
* Check if the connection is currently towards the master or not.
* Checks if the connection is currently towards the master or not.
*
* @return bool
* @return boolean
*/
public function isConnectedToMaster()
{
......@@ -194,10 +195,11 @@ class MasterSlaveConnection extends Connection
}
/**
* Connect to a specific connection
* Connects to a specific connection.
*
* @param string $connectionName
*
* @param string $connectionName
* @return Driver
* @return \Doctrine\DBAL\Driver
*/
protected function connectTo($connectionName)
{
......@@ -213,6 +215,12 @@ class MasterSlaveConnection extends Connection
return $this->_driver->connect($connectionParams, $user, $password, $driverOptions);
}
/**
* @param string $connectionName
* @param array $params
*
* @return mixed
*/
protected function chooseConnectionConfiguration($connectionName, $params)
{
if ($connectionName === 'master') {
......@@ -228,6 +236,7 @@ class MasterSlaveConnection extends Connection
public function executeUpdate($query, array $params = array(), array $types = array())
{
$this->connect('master');
return parent::executeUpdate($query, $params, $types);
}
......@@ -237,6 +246,7 @@ class MasterSlaveConnection extends Connection
public function beginTransaction()
{
$this->connect('master');
return parent::beginTransaction();
}
......@@ -246,6 +256,7 @@ class MasterSlaveConnection extends Connection
public function commit()
{
$this->connect('master');
return parent::commit();
}
......@@ -255,6 +266,7 @@ class MasterSlaveConnection extends Connection
public function rollBack()
{
$this->connect('master');
return parent::rollBack();
}
......@@ -264,6 +276,7 @@ class MasterSlaveConnection extends Connection
public function delete($tableName, array $identifier, array $types = array())
{
$this->connect('master');
return parent::delete($tableName, $identifier, $types);
}
......@@ -273,6 +286,7 @@ class MasterSlaveConnection extends Connection
public function update($tableName, array $data, array $identifier, array $types = array())
{
$this->connect('master');
return parent::update($tableName, $data, $identifier, $types);
}
......@@ -282,6 +296,7 @@ class MasterSlaveConnection extends Connection
public function insert($tableName, array $data, array $types = array())
{
$this->connect('master');
return parent::insert($tableName, $data, $types);
}
......@@ -291,6 +306,7 @@ class MasterSlaveConnection extends Connection
public function exec($statement)
{
$this->connect('master');
return parent::exec($statement);
}
......@@ -324,6 +340,9 @@ class MasterSlaveConnection extends Connection
return parent::rollbackSavepoint($savepoint);
}
/**
* {@inheritDoc}
*/
public function query()
{
$this->connect('master');
......@@ -344,6 +363,9 @@ class MasterSlaveConnection extends Connection
return $statement;
}
/**
* {@inheritDoc}
*/
public function prepare($statement)
{
$this->connect('master');
......
<?php
/*
* 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 MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\DBAL;
class DBALException extends \Exception
{
/**
* @param string $method
*
* @return \Doctrine\DBAL\DBALException
*/
public static function notSupported($method)
{
return new self("Operation '$method' is not supported by platform.");
}
/**
* @return \Doctrine\DBAL\DBALException
*/
public static function invalidPlatformSpecified()
{
return new self(
......@@ -16,6 +41,9 @@ class DBALException extends \Exception
"\Doctrine\DBAL\Platforms\AbstractPlatform.");
}
/**
* @return \Doctrine\DBAL\DBALException
*/
public static function invalidPdoInstance()
{
return new self(
......@@ -24,18 +52,34 @@ class DBALException extends \Exception
);
}
/**
* @return \Doctrine\DBAL\DBALException
*/
public static function driverRequired()
{
return new self("The options 'driver' or 'driverClass' are mandatory if no PDO ".
"instance is given to DriverManager::getConnection().");
}
/**
* @param string $unknownDriverName
* @param array $knownDrivers
*
* @return \Doctrine\DBAL\DBALException
*/
public static function unknownDriver($unknownDriverName, array $knownDrivers)
{
return new self("The given 'driver' ".$unknownDriverName." is unknown, ".
"Doctrine currently supports only the following drivers: ".implode(", ", $knownDrivers));
}
/**
* @param \Exception $driverEx
* @param string $sql
* @param array $params
*
* @return \Doctrine\DBAL\DBALException
*/
public static function driverExceptionDuringQuery(\Exception $driverEx, $sql, array $params = array())
{
$msg = "An exception occurred while executing '".$sql."'";
......@@ -69,12 +113,22 @@ class DBALException extends \Exception
}, $params)) . ']';
}
/**
* @param string $wrapperClass
*
* @return \Doctrine\DBAL\DBALException
*/
public static function invalidWrapperClass($wrapperClass)
{
return new self("The given 'wrapperClass' ".$wrapperClass." has to be a ".
"subtype of \Doctrine\DBAL\Connection.");
}
/**
* @param string $driverClass
*
* @return \Doctrine\DBAL\DBALException
*/
public static function invalidDriverClass($driverClass)
{
return new self("The given 'driverClass' ".$driverClass." has to implement the ".
......@@ -83,7 +137,8 @@ class DBALException extends \Exception
/**
* @param string $tableName
* @return DBALException
*
* @return \Doctrine\DBAL\DBALException
*/
public static function invalidTableName($tableName)
{
......@@ -92,23 +147,37 @@ class DBALException extends \Exception
/**
* @param string $tableName
* @return DBALException
*
* @return \Doctrine\DBAL\DBALException
*/
public static function noColumnsSpecifiedForTable($tableName)
{
return new self("No columns specified for table ".$tableName);
}
/**
* @return \Doctrine\DBAL\DBALException
*/
public static function limitOffsetInvalid()
{
return new self("Invalid Offset in Limit Query, it has to be larger or equal to 0.");
}
/**
* @param string $name
*
* @return \Doctrine\DBAL\DBALException
*/
public static function typeExists($name)
{
return new self('Type '.$name.' already exists.');
}
/**
* @param string $name
*
* @return \Doctrine\DBAL\DBALException
*/
public static function unknownColumnType($name)
{
return new self('Unknown column type "'.$name.'" requested. Any Doctrine type that you use has ' .
......@@ -121,6 +190,11 @@ class DBALException extends \Exception
);
}
/**
* @param string $name
*
* @return \Doctrine\DBAL\DBALException
*/
public static function typeNotFound($name)
{
return new self('Type to be overwritten '.$name.' does not exist.');
......
......@@ -30,10 +30,11 @@ interface 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.
* @param array $params All connection parameters passed by the user.
* @param string|null $username The username to use when connecting.
* @param string|null $password The password to use when connecting.
* @param array $driverOptions The driver options to use when connecting.
*
* @return \Doctrine\DBAL\Driver\Connection The database connection.
*/
public function connect(array $params, $username = null, $password = null, array $driverOptions = array());
......@@ -50,7 +51,8 @@ interface Driver
* Gets the SchemaManager that can be used to inspect and change the underlying
* database schema of the platform this driver connects to.
*
* @param \Doctrine\DBAL\Connection $conn
* @param \Doctrine\DBAL\Connection $conn
*
* @return \Doctrine\DBAL\Schema\AbstractSchemaManager
*/
public function getSchemaManager(Connection $conn);
......@@ -63,10 +65,11 @@ interface Driver
public function getName();
/**
* Get the name of the database connected to for this driver.
* Gets the name of the database connected to for this driver.
*
* @param \Doctrine\DBAL\Connection $conn
*
* @param \Doctrine\DBAL\Connection $conn
* @return string $database
* @return string The name of the database.
*/
public function getDatabase(Connection $conn);
}
......@@ -29,14 +29,82 @@ namespace Doctrine\DBAL\Driver;
*/
interface Connection
{
/**
* Prepares a statement for execution and returns a Statement object.
*
* @param string $prepareString
*
* @return \Doctrine\DBAL\Driver\Statement
*/
function prepare($prepareString);
/**
* Executes an SQL statement, returning a result set as a Statement object.
*
* @return \Doctrine\DBAL\Driver\Statement
*/
function query();
/**
* Quotes a string for use in a query.
*
* @param string $input
* @param integer $type
*
* @return string
*/
function quote($input, $type=\PDO::PARAM_STR);
/**
* Executes an SQL statement and return the number of affected rows.
*
* @param string $statement
*
* @return integer
*/
function exec($statement);
/**
* Returns the ID of the last inserted row or sequence value.
*
* @param string|null $name
*
* @return string
*/
function lastInsertId($name = null);
/**
* Initiates a transaction.
*
* @return boolean TRUE on success or FALSE on failure.
*/
function beginTransaction();
/**
* Commits a transaction.
*
* @return boolean TRUE on success or FALSE on failure.
*/
function commit();
/**
* Rolls back the current transaction, as initiated by beginTransaction().
*
* @return boolean TRUE on success or FALSE on failure.
*/
function rollBack();
/**
* Returns the error code associated with the last operation on the database handle.
*
* @return string|null The error code, or null if no operation has been run on the database handle.
*/
function errorCode();
/**
* Returns extended error information associated with the last operation on the database handle.
*
* @return array
*/
function errorInfo();
}
......@@ -43,7 +43,9 @@ class Driver implements \Doctrine\DBAL\Driver
/**
* Constructs the Drizzle MySql PDO DSN.
*
* @return string The DSN.
* @param array $params
*
* @return string The DSN.
*/
private function _constructPdoDsn(array $params)
{
......@@ -94,6 +96,7 @@ class Driver implements \Doctrine\DBAL\Driver
public function getDatabase(\Doctrine\DBAL\Connection $conn)
{
$params = $conn->getParams();
return $params['dbname'];
}
}
<?php
/*
* $Id$
*
* 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
......@@ -17,14 +15,25 @@
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
*/
namespace Doctrine\DBAL\Driver\IBMDB2;
class DB2Connection implements \Doctrine\DBAL\Driver\Connection
{
/**
* @var resource
*/
private $_conn = null;
/**
* @param array $params
* @param string $username
* @param string $password
* @param array $driverOptions
*
* @throws \Doctrine\DBAL\Driver\IBMDB2\DB2Exception
*/
public function __construct(array $params, $username, $password, $driverOptions = array())
{
$isPersistant = (isset($params['persistent']) && $params['persistent'] == true);
......@@ -39,6 +48,9 @@ class DB2Connection implements \Doctrine\DBAL\Driver\Connection
}
}
/**
* {@inheritdoc}
*/
public function prepare($sql)
{
$stmt = @db2_prepare($this->_conn, $sql);
......@@ -48,6 +60,9 @@ class DB2Connection implements \Doctrine\DBAL\Driver\Connection
return new DB2Statement($stmt);
}
/**
* {@inheritdoc}
*/
public function query()
{
$args = func_get_args();
......@@ -57,6 +72,9 @@ class DB2Connection implements \Doctrine\DBAL\Driver\Connection
return $stmt;
}
/**
* {@inheritdoc}
*/
public function quote($input, $type=\PDO::PARAM_STR)
{
$input = db2_escape_string($input);
......@@ -67,6 +85,9 @@ class DB2Connection implements \Doctrine\DBAL\Driver\Connection
}
}
/**
* {@inheritdoc}
*/
public function exec($statement)
{
$stmt = $this->prepare($statement);
......@@ -74,16 +95,25 @@ class DB2Connection implements \Doctrine\DBAL\Driver\Connection
return $stmt->rowCount();
}
/**
* {@inheritdoc}
*/
public function lastInsertId($name = null)
{
return db2_last_insert_id($this->_conn);
}
/**
* {@inheritdoc}
*/
public function beginTransaction()
{
db2_autocommit($this->_conn, DB2_AUTOCOMMIT_OFF);
}
/**
* {@inheritdoc}
*/
public function commit()
{
if (!db2_commit($this->_conn)) {
......@@ -92,6 +122,9 @@ class DB2Connection implements \Doctrine\DBAL\Driver\Connection
db2_autocommit($this->_conn, DB2_AUTOCOMMIT_ON);
}
/**
* {@inheritdoc}
*/
public function rollBack()
{
if (!db2_rollback($this->_conn)) {
......@@ -100,11 +133,17 @@ class DB2Connection implements \Doctrine\DBAL\Driver\Connection
db2_autocommit($this->_conn, DB2_AUTOCOMMIT_ON);
}
/**
* {@inheritdoc}
*/
public function errorCode()
{
return db2_conn_error($this->_conn);
}
/**
* {@inheritdoc}
*/
public function errorInfo()
{
return array(
......
......@@ -15,15 +15,15 @@
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
*/
namespace Doctrine\DBAL\Driver\IBMDB2;
use Doctrine\DBAL\Driver,
Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Connection;
/**
* IBM DB2 Driver
* IBM DB2 Driver.
*
* @since 2.0
* @author Benjamin Eberlei <kontakt@beberlei.de>
......@@ -31,13 +31,7 @@ use Doctrine\DBAL\Driver,
class DB2Driver implements 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\Driver\Connection The database connection.
* {@inheritdoc}
*/
public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
{
......@@ -65,10 +59,7 @@ class DB2Driver implements Driver
}
/**
* Gets the DatabasePlatform instance that provides all the metadata about
* the platform this driver connects to.
*
* @return \Doctrine\DBAL\Platforms\AbstractPlatform The database platform.
* {@inheritdoc}
*/
public function getDatabasePlatform()
{
......@@ -76,11 +67,7 @@ class DB2Driver implements Driver
}
/**
* Gets the SchemaManager that can be used to inspect and change the underlying
* database schema of the platform this driver connects to.
*
* @param \Doctrine\DBAL\Connection $conn
* @return \Doctrine\DBAL\Schema\DB2SchemaManager
* {@inheritdoc}
*/
public function getSchemaManager(Connection $conn)
{
......@@ -88,9 +75,7 @@ class DB2Driver implements Driver
}
/**
* Gets the name of the driver.
*
* @return string The name of the driver.
* {@inheritdoc}
*/
public function getName()
{
......@@ -98,14 +83,12 @@ class DB2Driver implements Driver
}
/**
* Get the name of the database connected to for this driver.
*
* @param \Doctrine\DBAL\Connection $conn
* @return string $database
* {@inheritdoc}
*/
public function getDatabase(\Doctrine\DBAL\Connection $conn)
{
$params = $conn->getParams();
return $params['dbname'];
}
}
<?php
/*
* $Id$
*
* 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
......@@ -17,11 +15,10 @@
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
*/
namespace Doctrine\DBAL\Driver\IBMDB2;
class DB2Exception extends \Exception
{
}
<?php
/*
* $Id$
*
* 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
......@@ -17,7 +15,7 @@
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
*/
namespace Doctrine\DBAL\Driver\IBMDB2;
......@@ -25,14 +23,24 @@ use \Doctrine\DBAL\Driver\Statement;
class DB2Statement implements \IteratorAggregate, Statement
{
/**
* @var resource
*/
private $_stmt = null;
/**
* @var array
*/
private $_bindParam = array();
/**
* @var integer
*/
private $_defaultFetchMode = \PDO::FETCH_BOTH;
/**
* DB2_BINARY, DB2_CHAR, DB2_DOUBLE, or DB2_LONG
*
* @var array
*/
static private $_typeMap = array(
......@@ -40,6 +48,9 @@ class DB2Statement implements \IteratorAggregate, Statement
\PDO::PARAM_STR => DB2_CHAR,
);
/**
* @param resource $stmt
*/
public function __construct($stmt)
{
$this->_stmt = $stmt;
......@@ -69,6 +80,7 @@ class DB2Statement implements \IteratorAggregate, Statement
if (!db2_bind_param($this->_stmt, $column, "variable", DB2_PARAM_IN, $type)) {
throw new DB2Exception(db2_stmt_errormsg());
}
return true;
}
......@@ -85,6 +97,7 @@ class DB2Statement implements \IteratorAggregate, Statement
db2_free_result($this->_stmt);
$ret = db2_free_stmt($this->_stmt);
$this->_stmt = false;
return $ret;
}
......@@ -96,6 +109,7 @@ class DB2Statement implements \IteratorAggregate, Statement
if ( ! $this->_stmt) {
return false;
}
return db2_num_fields($this->_stmt);
}
......@@ -142,6 +156,7 @@ class DB2Statement implements \IteratorAggregate, Statement
if ($retval === false) {
throw new DB2Exception(db2_stmt_errormsg());
}
return $retval;
}
......@@ -151,6 +166,8 @@ class DB2Statement implements \IteratorAggregate, Statement
public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null)
{
$this->_defaultFetchMode = $fetchMode;
return true;
}
/**
......@@ -159,6 +176,7 @@ class DB2Statement implements \IteratorAggregate, Statement
public function getIterator()
{
$data = $this->fetchAll();
return new \ArrayIterator($data);
}
......@@ -189,6 +207,7 @@ class DB2Statement implements \IteratorAggregate, Statement
while ($row = $this->fetch($fetchMode)) {
$rows[] = $row;
}
return $rows;
}
......@@ -201,6 +220,7 @@ class DB2Statement implements \IteratorAggregate, Statement
if ($row && isset($row[$columnIndex])) {
return $row[$columnIndex];
}
return false;
}
......
......@@ -64,6 +64,7 @@ class Driver implements DriverInterface
public function getDatabase(\Doctrine\DBAL\Connection $conn)
{
$params = $conn->getParams();
return $params['dbname'];
}
}
......@@ -31,6 +31,14 @@ class MysqliConnection implements Connection
*/
private $_conn;
/**
* @param array $params
* @param string $username
* @param string $password
* @param array $driverOptions
*
* @throws \Doctrine\DBAL\Driver\Mysqli\MysqliException
*/
public function __construct(array $params, $username, $password, array $driverOptions = array())
{
$port = isset($params['port']) ? $params['port'] : ini_get('mysqli.default_port');
......@@ -47,9 +55,9 @@ class MysqliConnection implements Connection
}
/**
* Retrieve mysqli native resource handle.
* Retrieves mysqli native resource handle.
*
* Could be used if part of your application is not using DBAL
* Could be used if part of your application is not using DBAL.
*
* @return \mysqli
*/
......
......@@ -15,7 +15,7 @@
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
*/
namespace Doctrine\DBAL\Driver\Mysqli;
......@@ -23,4 +23,5 @@ namespace Doctrine\DBAL\Driver\Mysqli;
* @author Kim Hemsø Rasmussen <kimhemsoe@gmail.com>
*/
class MysqliException extends \Exception
{}
{
}
......@@ -27,6 +27,9 @@ use PDO;
*/
class MysqliStatement implements \IteratorAggregate, Statement
{
/**
* @var array
*/
protected static $_paramTypeMap = array(
PDO::PARAM_STR => 's',
PDO::PARAM_BOOL => 'i',
......@@ -35,11 +38,18 @@ class MysqliStatement implements \IteratorAggregate, Statement
PDO::PARAM_LOB => 's' // TODO Support LOB bigger then max package size.
);
/**
* @var \mysqli
*/
protected $_conn;
/**
* @var \mysqli_stmt
*/
protected $_stmt;
/**
* @var null|false|array
* @var null|boolean|array
*/
protected $_columnNames;
......@@ -54,14 +64,23 @@ class MysqliStatement implements \IteratorAggregate, Statement
protected $_bindedValues;
/**
* Contains ref values for bindValue()
* Contains ref values for bindValue().
*
* @var array
*/
protected $_values = array();
/**
* @var integer
*/
protected $_defaultFetchMode = PDO::FETCH_BOTH;
/**
* @param \mysqli $conn
* @param string $prepareString
*
* @throws \Doctrine\DBAL\Driver\Mysqli\MysqliException
*/
public function __construct(\mysqli $conn, $prepareString)
{
$this->_conn = $conn;
......@@ -100,6 +119,7 @@ class MysqliStatement implements \IteratorAggregate, Statement
$this->_bindedValues[$column] =& $variable;
$this->_bindedValues[0][$column - 1] = $type;
return true;
}
......@@ -121,6 +141,7 @@ class MysqliStatement implements \IteratorAggregate, Statement
$this->_values[$param] = $value;
$this->_bindedValues[$param] =& $this->_values[$param];
$this->_bindedValues[0][$param - 1] = $type;
return true;
}
......@@ -174,13 +195,15 @@ class MysqliStatement implements \IteratorAggregate, Statement
if (false !== $this->_columnNames) {
$this->_stmt->store_result();
}
return true;
}
/**
* Bind a array of values to bound parameters
* Binds a array of values to bound parameters.
*
* @param array $values
*
* @return boolean
*/
private function _bindValues($values)
......@@ -192,6 +215,7 @@ class MysqliStatement implements \IteratorAggregate, Statement
foreach ($values as &$v) {
$params[] =& $v;
}
return call_user_func_array(array($this->_stmt, 'bind_param'), $params);
}
......@@ -210,6 +234,7 @@ class MysqliStatement implements \IteratorAggregate, Statement
}
return $values;
}
return $ret;
}
......@@ -276,6 +301,7 @@ class MysqliStatement implements \IteratorAggregate, Statement
if (null === $row) {
return false;
}
return $row[$columnIndex];
}
......@@ -301,6 +327,7 @@ class MysqliStatement implements \IteratorAggregate, Statement
public function closeCursor()
{
$this->_stmt->free_result();
return true;
}
......@@ -329,6 +356,8 @@ class MysqliStatement implements \IteratorAggregate, Statement
public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null)
{
$this->_defaultFetchMode = $fetchMode;
return true;
}
/**
......@@ -337,6 +366,7 @@ class MysqliStatement implements \IteratorAggregate, Statement
public function getIterator()
{
$data = $this->fetchAll();
return new \ArrayIterator($data);
}
}
<?php
/*
* $Id$
*
* 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
......@@ -31,6 +29,9 @@ use Doctrine\DBAL\Platforms;
*/
class Driver implements \Doctrine\DBAL\Driver
{
/**
* {@inheritdoc}
*/
public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
{
return new OCI8Connection(
......@@ -46,6 +47,8 @@ class Driver implements \Doctrine\DBAL\Driver
/**
* Constructs the Oracle DSN.
*
* @param array $params
*
* @return string The DSN.
*/
protected function _constructDsn(array $params)
......@@ -73,27 +76,41 @@ class Driver implements \Doctrine\DBAL\Driver
} else {
$dsn .= $params['dbname'];
}
return $dsn;
}
/**
* {@inheritdoc}
*/
public function getDatabasePlatform()
{
return new \Doctrine\DBAL\Platforms\OraclePlatform();
}
/**
* {@inheritdoc}
*/
public function getSchemaManager(\Doctrine\DBAL\Connection $conn)
{
return new \Doctrine\DBAL\Schema\OracleSchemaManager($conn);
}
/**
* {@inheritdoc}
*/
public function getName()
{
return 'oci8';
}
/**
* {@inheritdoc}
*/
public function getDatabase(\Doctrine\DBAL\Connection $conn)
{
$params = $conn->getParams();
return $params['user'];
}
}
......@@ -34,16 +34,21 @@ class OCI8Connection implements \Doctrine\DBAL\Driver\Connection
protected $dbh;
/**
* @var int
* @var integer
*/
protected $executeMode = OCI_COMMIT_ON_SUCCESS;
/**
* Create a Connection to an Oracle Database using oci8 extension.
* Creates a Connection to an Oracle Database using oci8 extension.
*
* @param string $username
* @param string $password
* @param string $db
* @param string $username
* @param string $password
* @param string $db
* @param string|null $charset
* @param integer $sessionMode
* @param boolean $persistent
*
* @throws OCI8Exception
*/
public function __construct($username, $password, $db, $charset = null, $sessionMode = OCI_DEFAULT, $persistent = false)
{
......@@ -61,10 +66,7 @@ class OCI8Connection implements \Doctrine\DBAL\Driver\Connection
}
/**
* Create a non-executed prepared statement.
*
* @param string $prepareString
* @return OCI8Statement
* {@inheritdoc}
*/
public function prepare($prepareString)
{
......@@ -72,8 +74,7 @@ class OCI8Connection implements \Doctrine\DBAL\Driver\Connection
}
/**
* @param string $sql
* @return OCI8Statement
* {@inheritdoc}
*/
public function query()
{
......@@ -82,15 +83,12 @@ class OCI8Connection implements \Doctrine\DBAL\Driver\Connection
//$fetchMode = $args[1];
$stmt = $this->prepare($sql);
$stmt->execute();
return $stmt;
}
/**
* Quote input value.
*
* @param mixed $input
* @param int $type PDO::PARAM*
* @return mixed
* {@inheritdoc}
*/
public function quote($value, $type=\PDO::PARAM_STR)
{
......@@ -98,23 +96,23 @@ class OCI8Connection implements \Doctrine\DBAL\Driver\Connection
return $value;
}
$value = str_replace("'", "''", $value);
return "'" . addcslashes($value, "\000\n\r\\\032") . "'";
}
/**
*
* @param string $statement
* @return int
* {@inheritdoc}
*/
public function exec($statement)
{
$stmt = $this->prepare($statement);
$stmt->execute();
return $stmt->rowCount();
}
/**
* {@inheritDoc}
* {@inheritdoc}
*/
public function lastInsertId($name = null)
{
......@@ -136,7 +134,9 @@ class OCI8Connection implements \Doctrine\DBAL\Driver\Connection
}
/**
* Return the current execution mode.
* Returns the current execution mode.
*
* @return integer
*/
public function getExecuteMode()
{
......@@ -144,23 +144,17 @@ class OCI8Connection implements \Doctrine\DBAL\Driver\Connection
}
/**
* Start a transactiom
*
* Oracle has to explicitly set the autocommit mode off. That means
* after connection, a commit or rollback there is always automatically
* opened a new transaction.
*
* @return bool
* {@inheritdoc}
*/
public function beginTransaction()
{
$this->executeMode = OCI_NO_AUTO_COMMIT;
return true;
}
/**
* @throws OCI8Exception
* @return bool
* {@inheritdoc}
*/
public function commit()
{
......@@ -168,12 +162,12 @@ class OCI8Connection implements \Doctrine\DBAL\Driver\Connection
throw OCI8Exception::fromErrorInfo($this->errorInfo());
}
$this->executeMode = OCI_COMMIT_ON_SUCCESS;
return true;
}
/**
* @throws OCI8Exception
* @return bool
* {@inheritdoc}
*/
public function rollBack()
{
......@@ -181,18 +175,26 @@ class OCI8Connection implements \Doctrine\DBAL\Driver\Connection
throw OCI8Exception::fromErrorInfo($this->errorInfo());
}
$this->executeMode = OCI_COMMIT_ON_SUCCESS;
return true;
}
/**
* {@inheritdoc}
*/
public function errorCode()
{
$error = oci_error($this->dbh);
if ($error !== false) {
$error = $error['code'];
}
return $error;
}
/**
* {@inheritdoc}
*/
public function errorInfo()
{
return oci_error($this->dbh);
......
<?php
/*
* $Id$
*
* 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
......@@ -17,12 +15,17 @@
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
*/
namespace Doctrine\DBAL\Driver\OCI8;
class OCI8Exception extends \Exception
{
/**
* @param array $error
*
* @return \Doctrine\DBAL\Driver\OCI8\OCI8Exception
*/
static public function fromErrorInfo($error)
{
return new self($error['message'], $error['code']);
......
......@@ -31,11 +31,29 @@ use Doctrine\DBAL\Driver\Statement;
*/
class OCI8Statement implements \IteratorAggregate, Statement
{
/** Statement handle. */
/**
* @var resource
*/
protected $_dbh;
/**
* @var resource
*/
protected $_sth;
/**
* @var \Doctrine\DBAL\Driver\OCI8\OCI8Connection
*/
protected $_conn;
/**
* @var string
*/
protected static $_PARAM = ':param';
/**
* @var array
*/
protected static $fetchModeMap = array(
PDO::FETCH_BOTH => OCI_BOTH,
PDO::FETCH_ASSOC => OCI_ASSOC,
......@@ -43,14 +61,23 @@ class OCI8Statement implements \IteratorAggregate, Statement
PDO::PARAM_LOB => OCI_B_BLOB,
PDO::FETCH_COLUMN => OCI_NUM,
);
/**
* @var integer
*/
protected $_defaultFetchMode = PDO::FETCH_BOTH;
/**
* @var array
*/
protected $_paramMap = array();
/**
* Creates a new OCI8Statement that uses the given connection handle and SQL statement.
*
* @param resource $dbh The connection handle.
* @param string $statement The SQL statement.
* @param resource $dbh The connection handle.
* @param string $statement The SQL statement.
* @param \Doctrine\DBAL\Driver\OCI8\OCI8Connection $conn
*/
public function __construct($dbh, $statement, OCI8Connection $conn)
{
......@@ -62,7 +89,7 @@ class OCI8Statement implements \IteratorAggregate, Statement
}
/**
* Convert positional (?) into named placeholders (:param<num>)
* Converts positional (?) into named placeholders (:param<num>).
*
* Oracle does not support positional parameters, hence this method converts all
* positional parameters into artificially named parameters. Note that this conversion
......@@ -75,7 +102,9 @@ class OCI8Statement implements \IteratorAggregate, Statement
*
* @todo extract into utility class in Doctrine\DBAL\Util namespace
* @todo review and test for lost spaces. we experienced missing spaces with oci8 in some sql statements.
*
* @param string $statement The SQL statement to convert.
*
* @return string
*/
static public function convertPositionalToNamedPlaceholders($statement)
......@@ -129,9 +158,7 @@ class OCI8Statement implements \IteratorAggregate, Statement
}
/**
* Closes the cursor, enabling the statement to be executed again.
*
* @return boolean Returns TRUE on success or FALSE on failure.
* {@inheritdoc}
*/
public function closeCursor()
{
......@@ -155,6 +182,7 @@ class OCI8Statement implements \IteratorAggregate, Statement
if ($error !== false) {
$error = $error['code'];
}
return $error;
}
......@@ -186,6 +214,7 @@ class OCI8Statement implements \IteratorAggregate, Statement
if ( ! $ret) {
throw OCI8Exception::fromErrorInfo($this->errorInfo());
}
return $ret;
}
......@@ -195,6 +224,8 @@ class OCI8Statement implements \IteratorAggregate, Statement
public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null)
{
$this->_defaultFetchMode = $fetchMode;
return true;
}
/**
......@@ -203,6 +234,7 @@ class OCI8Statement implements \IteratorAggregate, Statement
public function getIterator()
{
$data = $this->fetchAll();
return new \ArrayIterator($data);
}
......@@ -257,6 +289,7 @@ class OCI8Statement implements \IteratorAggregate, Statement
public function fetchColumn($columnIndex = 0)
{
$row = oci_fetch_array($this->_sth, OCI_NUM | OCI_RETURN_NULLS | OCI_RETURN_LOBS);
return isset($row[$columnIndex]) ? $row[$columnIndex] : false;
}
......
<?php
/*
* $Id$
*
* 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
......@@ -21,7 +19,7 @@
namespace Doctrine\DBAL\Driver;
use \PDO;
use PDO;
/**
* PDO implementation of the Connection interface.
......@@ -31,6 +29,12 @@ use \PDO;
*/
class PDOConnection extends PDO implements Connection
{
/**
* @param string $dsn
* @param string|null $user
* @param string|null $password
* @param array|null $options
*/
public function __construct($dsn, $user = null, $password = null, array $options = null)
{
parent::__construct($dsn, $user, $password, $options);
......
<?php
/*
* $Id$
*
* 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
......@@ -17,34 +15,26 @@
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
*/
namespace Doctrine\DBAL\Driver\PDOIbm;
use Doctrine\DBAL\Connection;
/**
* Driver for the PDO IBM extension
* Driver for the PDO IBM extension.
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.com
* @since 1.0
* @version $Revision$
* @author Benjamin Eberlei <kontakt@beberlei.de>
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
* @link www.doctrine-project.org
* @since 1.0
* @author Benjamin Eberlei <kontakt@beberlei.de>
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
class Driver implements \Doctrine\DBAL\Driver
{
/**
* Attempts to establish a connection with the underlying driver.
*
* @param array $params
* @param string $username
* @param string $password
* @param array $driverOptions
* @return \Doctrine\DBAL\Driver\Connection
* {@inheritdoc}
*/
public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
{
......@@ -54,13 +44,16 @@ class Driver implements \Doctrine\DBAL\Driver
$password,
$driverOptions
);
return $conn;
}
/**
* Constructs the MySql PDO DSN.
* Constructs the IBM PDO DSN.
*
* @param array $params
*
* @return string The DSN.
* @return string The DSN.
*/
private function _constructPdoDsn(array $params)
{
......@@ -80,10 +73,7 @@ class Driver implements \Doctrine\DBAL\Driver
}
/**
* Gets the DatabasePlatform instance that provides all the metadata about
* the platform this driver connects to.
*
* @return \Doctrine\DBAL\Platforms\AbstractPlatform The database platform.
* {@inheritdoc}
*/
public function getDatabasePlatform()
{
......@@ -91,11 +81,7 @@ class Driver implements \Doctrine\DBAL\Driver
}
/**
* Gets the SchemaManager that can be used to inspect and change the underlying
* database schema of the platform this driver connects to.
*
* @param \Doctrine\DBAL\Connection $conn
* @return \Doctrine\DBAL\Schema\DB2SchemaManager
* {@inheritdoc}
*/
public function getSchemaManager(Connection $conn)
{
......@@ -103,9 +89,7 @@ class Driver implements \Doctrine\DBAL\Driver
}
/**
* Gets the name of the driver.
*
* @return string The name of the driver.
* {@inheritdoc}
*/
public function getName()
{
......@@ -113,14 +97,12 @@ class Driver implements \Doctrine\DBAL\Driver
}
/**
* Get the name of the database connected to for this driver.
*
* @param \Doctrine\DBAL\Connection $conn
* @return string $database
* {@inheritdoc}
*/
public function getDatabase(\Doctrine\DBAL\Connection $conn)
{
$params = $conn->getParams();
return $params['dbname'];
}
}
......@@ -29,13 +29,7 @@ use Doctrine\DBAL\Connection;
class Driver implements \Doctrine\DBAL\Driver
{
/**
* Attempts to establish a connection with the underlying driver.
*
* @param array $params
* @param string $username
* @param string $password
* @param array $driverOptions
* @return \Doctrine\DBAL\Driver\Connection
* {@inheritdoc}
*/
public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
{
......@@ -45,13 +39,16 @@ class Driver implements \Doctrine\DBAL\Driver
$password,
$driverOptions
);
return $conn;
}
/**
* Constructs the MySql PDO DSN.
*
* @return string The DSN.
* @param array $params
*
* @return string The DSN.
*/
private function _constructPdoDsn(array $params)
{
......@@ -75,21 +72,33 @@ class Driver implements \Doctrine\DBAL\Driver
return $dsn;
}
/**
* {@inheritdoc}
*/
public function getDatabasePlatform()
{
return new \Doctrine\DBAL\Platforms\MySqlPlatform();
}
/**
* {@inheritdoc}
*/
public function getSchemaManager(\Doctrine\DBAL\Connection $conn)
{
return new \Doctrine\DBAL\Schema\MySqlSchemaManager($conn);
}
/**
* {@inheritdoc}
*/
public function getName()
{
return 'pdo_mysql';
}
/**
* {@inheritdoc}
*/
public function getDatabase(\Doctrine\DBAL\Connection $conn)
{
$params = $conn->getParams();
......
......@@ -22,7 +22,7 @@ namespace Doctrine\DBAL\Driver\PDOOracle;
use Doctrine\DBAL\Platforms;
/**
* PDO Oracle driver
* PDO Oracle driver.
*
* WARNING: This driver gives us segfaults in our testsuites on CLOB and other
* stuff. PDO Oracle is not maintained by Oracle or anyone in the PHP community,
......@@ -31,6 +31,9 @@ use Doctrine\DBAL\Platforms;
*/
class Driver implements \Doctrine\DBAL\Driver
{
/**
* {@inheritdoc}
*/
public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
{
return new \Doctrine\DBAL\Driver\PDOConnection(
......@@ -44,7 +47,9 @@ class Driver implements \Doctrine\DBAL\Driver
/**
* Constructs the Oracle PDO DSN.
*
* @return string The DSN.
* @param array $params
*
* @return string The DSN.
*/
private function _constructPdoDsn(array $params)
{
......@@ -75,24 +80,37 @@ class Driver implements \Doctrine\DBAL\Driver
return $dsn;
}
/**
* {@inheritdoc}
*/
public function getDatabasePlatform()
{
return new \Doctrine\DBAL\Platforms\OraclePlatform();
}
/**
* {@inheritdoc}
*/
public function getSchemaManager(\Doctrine\DBAL\Connection $conn)
{
return new \Doctrine\DBAL\Schema\OracleSchemaManager($conn);
}
/**
* {@inheritdoc}
*/
public function getName()
{
return 'pdo_oracle';
}
/**
* {@inheritdoc}
*/
public function getDatabase(\Doctrine\DBAL\Connection $conn)
{
$params = $conn->getParams();
return $params['user'];
}
}
<?php
/*
* 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 MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\DBAL\Driver\PDOPgSql;
......@@ -12,9 +29,7 @@ use Doctrine\DBAL\Platforms;
class Driver implements \Doctrine\DBAL\Driver
{
/**
* Attempts to connect to the database and returns a driver connection on success.
*
* @return \Doctrine\DBAL\Driver\Connection
* {@inheritdoc}
*/
public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
{
......@@ -29,6 +44,8 @@ class Driver implements \Doctrine\DBAL\Driver
/**
* Constructs the Postgres PDO DSN.
*
* @param array $params
*
* @return string The DSN.
*/
private function _constructPdoDsn(array $params)
......@@ -47,27 +64,40 @@ class Driver implements \Doctrine\DBAL\Driver
return $dsn;
}
/**
* {@inheritdoc}
*/
public function getDatabasePlatform()
{
return new \Doctrine\DBAL\Platforms\PostgreSqlPlatform();
}
/**
* {@inheritdoc}
*/
public function getSchemaManager(\Doctrine\DBAL\Connection $conn)
{
return new \Doctrine\DBAL\Schema\PostgreSqlSchemaManager($conn);
}
/**
* {@inheritdoc}
*/
public function getName()
{
return 'pdo_pgsql';
}
/**
* {@inheritdoc}
*/
public function getDatabase(\Doctrine\DBAL\Connection $conn)
{
$params = $conn->getParams();
return (isset($params['dbname']))
? $params['dbname']
: $conn->query('SELECT CURRENT_DATABASE()')->fetchColumn();
}
}
......@@ -36,13 +36,7 @@ class Driver implements \Doctrine\DBAL\Driver
);
/**
* Tries to establish a database connection to SQLite.
*
* @param array $params
* @param string $username
* @param string $password
* @param array $driverOptions
* @return \Doctrine\DBAL\Driver\PDOConnection
* {@inheritdoc}
*/
public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
{
......@@ -69,8 +63,9 @@ class Driver implements \Doctrine\DBAL\Driver
/**
* Constructs the Sqlite PDO DSN.
*
* @return string The DSN.
* @override
* @param array $params
*
* @return string The DSN.
*/
protected function _constructPdoDsn(array $params)
{
......@@ -85,7 +80,7 @@ class Driver implements \Doctrine\DBAL\Driver
}
/**
* Gets the database platform that is relevant for this driver.
* {@inheritdoc}
*/
public function getDatabasePlatform()
{
......@@ -93,24 +88,28 @@ class Driver implements \Doctrine\DBAL\Driver
}
/**
* Gets the schema manager that is relevant for this driver.
*
* @param \Doctrine\DBAL\Connection $conn
* @return \Doctrine\DBAL\Schema\SqliteSchemaManager
* {@inheritdoc}
*/
public function getSchemaManager(\Doctrine\DBAL\Connection $conn)
{
return new \Doctrine\DBAL\Schema\SqliteSchemaManager($conn);
}
/**
* {@inheritdoc}
*/
public function getName()
{
return 'pdo_sqlite';
}
/**
* {@inheritdoc}
*/
public function getDatabase(\Doctrine\DBAL\Connection $conn)
{
$params = $conn->getParams();
return isset($params['path']) ? $params['path'] : null;
}
}
<?php
/*
* $Id$
*
* 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
......
......@@ -26,6 +26,9 @@ namespace Doctrine\DBAL\Driver\PDOSqlsrv;
*/
class Driver implements \Doctrine\DBAL\Driver
{
/**
* {@inheritdoc}
*/
public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
{
return new Connection(
......@@ -39,7 +42,9 @@ class Driver implements \Doctrine\DBAL\Driver
/**
* Constructs the Sqlsrv PDO DSN.
*
* @return string The DSN.
* @param array $params
*
* @return string The DSN.
*/
private function _constructPdoDsn(array $params)
{
......@@ -64,24 +69,37 @@ class Driver implements \Doctrine\DBAL\Driver
return $dsn;
}
/**
* {@inheritdoc}
*/
public function getDatabasePlatform()
{
return new \Doctrine\DBAL\Platforms\SQLServer2008Platform();
}
/**
* {@inheritdoc}
*/
public function getSchemaManager(\Doctrine\DBAL\Connection $conn)
{
return new \Doctrine\DBAL\Schema\SQLServerSchemaManager($conn);
}
/**
* {@inheritdoc}
*/
public function getName()
{
return 'pdo_sqlsrv';
}
/**
* {@inheritdoc}
*/
public function getDatabase(\Doctrine\DBAL\Connection $conn)
{
$params = $conn->getParams();
return $params['dbname'];
}
}
<?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
......@@ -29,8 +27,16 @@ namespace Doctrine\DBAL\Driver;
*/
class PDOStatement extends \PDOStatement implements Statement
{
private function __construct() {}
/**
* Private constructor.
*/
private function __construct()
{
}
/**
* {@inheritdoc}
*/
public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null)
{
// This thin wrapper is necessary to shield against the weird signature
......
......@@ -29,63 +29,60 @@ interface ResultStatement extends \Traversable
/**
* Closes the cursor, enabling the statement to be executed again.
*
* @return boolean Returns TRUE on success or FALSE on failure.
* @return boolean TRUE on success or FALSE on failure.
*/
function closeCursor();
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 PDOStatement object. If there is no result set,
* this method should return 0.
* @return integer The number of columns in the result set represented
* by the PDOStatement object. If there is no result set,
* this method should return 0.
*/
function columnCount();
public function columnCount();
/**
* setFetchMode
* Set the fetch mode to use while iterating this statement.
* Sets the fetch mode to use while iterating this statement.
*
* @param integer $fetchMode
* @param mixed $arg2
* @param mixed $arg3
*
* @return boolean
*/
function setFetchMode($fetchMode, $arg2 = null, $arg3 = null);
public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null);
/**
* fetch
*
* @see Query::HYDRATE_* constants
* @param integer $fetchMode Controls how the next row will be returned to the caller.
* This value must be one of the Query::HYDRATE_* constants,
* defaulting to Query::HYDRATE_BOTH
*
* @param integer|null $fetchMode Controls how the next row will be returned to the caller.
* This value must be one of the Query::HYDRATE_* constants,
* defaulting to Query::HYDRATE_BOTH
*
* @return mixed
*/
function fetch($fetchMode = null);
public function fetch($fetchMode = null);
/**
* Returns an array containing all of the result set rows
* Returns an array containing all of the result set rows.
*
* @param integer $fetchMode Controls how the next row will be returned to the caller.
* This value must be one of the Query::HYDRATE_* constants,
* defaulting to Query::HYDRATE_BOTH
* @param integer|null $fetchMode Controls how the next row will be returned to the caller.
* This value must be one of the Query::HYDRATE_* constants,
* defaulting to Query::HYDRATE_BOTH
*
* @return array
*/
function fetchAll($fetchMode = null);
public function fetchAll($fetchMode = null);
/**
* fetchColumn
* Returns a single column from the next row of a
* result set or FALSE if there are no more rows.
* 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, PDOStatement->fetchColumn()
* fetches the first column.
* @param integer $columnIndex 0-indexed number of the column you wish to retrieve from the row.
* If no value is supplied, PDOStatement->fetchColumn()
* fetches the first column.
*
* @return string returns a single column in the next row of a result set.
* @return string|boolean A single column in the next row of a result set, or FALSE if there are no more rows.
*/
function fetchColumn($columnIndex = 0);
public function fetchColumn($columnIndex = 0);
}
......@@ -20,10 +20,13 @@
namespace Doctrine\DBAL\Driver\SQLSrv;
/**
* Driver for ext/sqlsrv
* Driver for ext/sqlsrv.
*/
class Driver implements \Doctrine\DBAL\Driver
{
/**
* {@inheritdoc}
*/
public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
{
if (!isset($params['host'])) {
......@@ -48,25 +51,36 @@ class Driver implements \Doctrine\DBAL\Driver
return new SQLSrvConnection($serverName, $driverOptions);
}
/**
* {@inheritdoc}
*/
public function getDatabasePlatform()
{
return new \Doctrine\DBAL\Platforms\SQLServer2008Platform();
}
/**
* {@inheritdoc}
*/
public function getSchemaManager(\Doctrine\DBAL\Connection $conn)
{
return new \Doctrine\DBAL\Schema\SQLServerSchemaManager($conn);
}
/**
* {@inheritdoc}
*/
public function getName()
{
return 'sqlsrv';
}
/**
* {@inheritdoc}
*/
public function getDatabase(\Doctrine\DBAL\Connection $conn)
{
$params = $conn->getParams();
return $params['dbname'];
}
}
......@@ -20,23 +20,31 @@
namespace Doctrine\DBAL\Driver\SQLSrv;
/**
* Last Id Data Container
* Last Id Data Container.
*
* @since 2.3
* @author Benjamin Eberlei <kontakt@beberlei.de>
*/
class LastInsertId
{
/**
* @var integer
*/
private $id;
/**
* @param integer $id
*/
public function setId($id)
{
$this->id = $id;
}
/**
* @return integer
*/
public function getId()
{
return $this->id;
}
}
......@@ -33,11 +33,16 @@ class SQLSrvConnection implements \Doctrine\DBAL\Driver\Connection
protected $conn;
/**
* @var LastInsertId
* @var \Doctrine\DBAL\Driver\SQLSrv\LastInsertId
*/
protected $lastInsertId;
/**
* @param string $serverName
* @param array $connectionOptions
*
* @throws \Doctrine\DBAL\Driver\SQLSrv\SQLSrvException
*/
public function __construct($serverName, $connectionOptions)
{
$this->conn = sqlsrv_connect($serverName, $connectionOptions);
......@@ -64,6 +69,7 @@ class SQLSrvConnection implements \Doctrine\DBAL\Driver\Connection
$sql = $args[0];
$stmt = $this->prepare($sql);
$stmt->execute();
return $stmt;
}
......@@ -89,6 +95,7 @@ class SQLSrvConnection implements \Doctrine\DBAL\Driver\Connection
{
$stmt = $this->prepare($statement);
$stmt->execute();
return $stmt->rowCount();
}
......@@ -147,6 +154,7 @@ class SQLSrvConnection implements \Doctrine\DBAL\Driver\Connection
if ($errors) {
return $errors[0]['code'];
}
return false;
}
......@@ -158,4 +166,3 @@ class SQLSrvConnection implements \Doctrine\DBAL\Driver\Connection
return sqlsrv_errors(SQLSRV_ERR_ERRORS);
}
}
......@@ -24,7 +24,7 @@ class SQLSrvException extends \Doctrine\DBAL\DBALException
/**
* Helper method to turn sql server errors into exception.
*
* @return SQLSrvException
* @return \Doctrine\DBAL\Driver\SQLSrv\SQLSrvException
*/
static public function fromSqlSrvErrors()
{
......@@ -40,4 +40,3 @@ class SQLSrvException extends \Doctrine\DBAL\DBALException
return new self(rtrim($message));
}
}
......@@ -24,7 +24,7 @@ use IteratorAggregate;
use Doctrine\DBAL\Driver\Statement;
/**
* SQL Server Statement
* SQL Server Statement.
*
* @since 2.3
* @author Benjamin Eberlei <kontakt@beberlei.de>
......@@ -32,35 +32,35 @@ use Doctrine\DBAL\Driver\Statement;
class SQLSrvStatement implements IteratorAggregate, Statement
{
/**
* SQLSRV Resource
* The SQLSRV Resource.
*
* @var resource
*/
private $conn;
/**
* SQL Statement to execute
* The SQL statement to execute.
*
* @var string
*/
private $sql;
/**
* SQLSRV Statement Resource
* The SQLSRV statement resource.
*
* @var resource
*/
private $stmt;
/**
* Parameters to bind
* Parameters to bind.
*
* @var array
*/
private $params = array();
/**
* Translations
* Translations.
*
* @var array
*/
......@@ -71,14 +71,16 @@ class SQLSrvStatement implements IteratorAggregate, Statement
);
/**
* Fetch Style
* The fetch style.
*
* @param int
* @param integer
*/
private $defaultFetchMode = PDO::FETCH_BOTH;
/**
* @var int|null
* The last insert ID.
*
* @var \Doctrine\DBAL\Driver\SQLSrv\LastInsertId|null
*/
private $lastInsertId;
......@@ -89,6 +91,11 @@ class SQLSrvStatement implements IteratorAggregate, Statement
*/
const LAST_INSERT_ID_SQL = ';SELECT SCOPE_IDENTITY() AS LastInsertId;';
/**
* @param resource $conn
* @param string $sql
* @param integer|null $lastInsertId
*/
public function __construct($conn, $sql, $lastInsertId = null)
{
$this->conn = $conn;
......@@ -100,6 +107,9 @@ class SQLSrvStatement implements IteratorAggregate, Statement
}
}
/**
* {@inheritdoc}
*/
public function bindValue($param, $value, $type = null)
{
return $this->bindParam($param, $value, $type,null);
......@@ -121,6 +131,9 @@ class SQLSrvStatement implements IteratorAggregate, Statement
}
}
/**
* {@inheritdoc}
*/
public function closeCursor()
{
if ($this->stmt) {
......@@ -128,13 +141,16 @@ class SQLSrvStatement implements IteratorAggregate, Statement
}
}
/**
* {@inheritdoc}
*/
public function columnCount()
{
return sqlsrv_num_fields($this->stmt);
}
/**
* {@inheritDoc}
* {@inheritdoc}
*/
public function errorCode()
{
......@@ -142,17 +158,21 @@ class SQLSrvStatement implements IteratorAggregate, Statement
if ($errors) {
return $errors[0]['code'];
}
return false;
}
/**
* {@inheritDoc}
* {@inheritdoc}
*/
public function errorInfo()
{
return sqlsrv_errors(SQLSRV_ERR_ERRORS);
}
/**
* {@inheritdoc}
*/
public function execute($params = null)
{
if ($params) {
......@@ -175,9 +195,14 @@ class SQLSrvStatement implements IteratorAggregate, Statement
}
}
/**
* {@inheritdoc}
*/
public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null)
{
$this->defaultFetchMode = $fetchMode;
return true;
}
/**
......@@ -186,6 +211,7 @@ class SQLSrvStatement implements IteratorAggregate, Statement
public function getIterator()
{
$data = $this->fetchAll();
return new \ArrayIterator($data);
}
......@@ -228,6 +254,7 @@ class SQLSrvStatement implements IteratorAggregate, Statement
while ($row = $this->fetch($fetchMode, $className, $ctorArgs)) {
$rows[] = $row;
}
return $rows;
}
......@@ -237,6 +264,7 @@ class SQLSrvStatement implements IteratorAggregate, Statement
public function fetchColumn($columnIndex = 0)
{
$row = $this->fetch(PDO::FETCH_NUM);
return $row[$columnIndex];
}
......@@ -248,4 +276,3 @@ class SQLSrvStatement implements IteratorAggregate, Statement
return sqlsrv_rows_affected($this->stmt);
}
}
......@@ -25,11 +25,10 @@ namespace Doctrine\DBAL\Driver;
*
* This resembles (a subset of) the PDOStatement interface.
*
* @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
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Roman Borschel <roman@code-factory.org>
* @link www.doctrine-project.org
* @since 2.0
*/
interface Statement extends ResultStatement
{
......@@ -37,14 +36,13 @@ interface Statement extends ResultStatement
* Binds a value to a corresponding named or positional
* placeholder in the SQL statement that was used 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 $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 PDO::PARAM_* constants.
*
* @param mixed $value The value to bind to the parameter.
* @param integer $type Explicit data type for the parameter using the PDO::PARAM_* constants.
*
* @return boolean Returns TRUE on success or FALSE on failure.
* @return boolean TRUE on success or FALSE on failure.
*/
function bindValue($param, $value, $type = null);
......@@ -59,35 +57,35 @@ interface Statement extends ResultStatement
* 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 $column 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 mixed $column 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|null $type Explicit data type for the parameter using the PDO::PARAM_* constants. To return
* an INOUT parameter from a stored procedure, use the bitwise OR operator to set the
* PDO::PARAM_INPUT_OUTPUT bits for the data_type parameter.
* @param integer|null $length You must specify maxlength when using an OUT bind
* so that PHP allocates enough memory to hold the returned value.
*
* @param integer $type Explicit data type for the parameter using the PDO::PARAM_* constants. To return
* an INOUT parameter from a stored procedure, use the bitwise OR operator to set the
* PDO::PARAM_INPUT_OUTPUT bits for the data_type parameter.
* @param integer $length You must specify maxlength when using an OUT bind so that PHP allocates enough memory to hold the returned value.
* @return boolean Returns TRUE on success or FALSE on failure.
* @return boolean TRUE on success or FALSE on failure.
*/
function bindParam($column, &$variable, $type = null, $length = null);
/**
* errorCode
* Fetch the SQLSTATE associated with the last operation on the statement handle
* Fetches the SQLSTATE associated with the last operation on the statement handle.
*
* @see Doctrine_Adapter_Interface::errorCode()
* @return string error code string
*
* @return string The error code string.
*/
function errorCode();
/**
* errorInfo
* Fetch extended error information associated with the last operation on the statement handle
* Fetches extended error information associated with the last operation on the statement handle.
*
* @see Doctrine_Adapter_Interface::errorInfo()
* @return array error info array
*
* @return array The error info array.
*/
function errorInfo();
......@@ -98,18 +96,18 @@ interface Statement extends ResultStatement
* 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
* parameter values.
*
*
* @param array|null $params An array of values with as many elements as there are
* bound parameters in the SQL statement being executed.
*
* @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.
* @return boolean TRUE on success or FALSE on failure.
*/
function execute($params = null);
/**
* rowCount
* rowCount() returns the number of rows affected by the last DELETE, INSERT, or UPDATE statement
* 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,
......@@ -117,7 +115,7 @@ interface Statement extends ResultStatement
* this behaviour is not guaranteed for all databases and should not be
* relied on for portable applications.
*
* @return integer Returns the number of rows.
* @return integer The number of rows.
*/
function rowCount();
}
......@@ -51,8 +51,12 @@ final class DriverManager
'sqlsrv' => 'Doctrine\DBAL\Driver\SQLSrv\Driver',
);
/** Private constructor. This class cannot be instantiated. */
private function __construct() { }
/**
* Private constructor. This class cannot be instantiated.
*/
private function __construct()
{
}
/**
* Creates a connection object based on the specified parameters.
......@@ -101,10 +105,13 @@ final class DriverManager
* <b>driverClass</b>:
* The driver class to use.
*
* @param array $params The parameters.
* @param \Doctrine\DBAL\Configuration The configuration to use.
* @param \Doctrine\Common\EventManager The event manager to use.
* @param array $params The parameters.
* @param \Doctrine\DBAL\Configuration|null $config The configuration to use.
* @param \Doctrine\Common\EventManager|null $eventManager The event manager to use.
*
* @return \Doctrine\DBAL\Connection
*
* @throws \Doctrine\DBAL\DBALException
*/
public static function getConnection(
array $params,
......@@ -151,7 +158,11 @@ final class DriverManager
/**
* Checks the list of parameters.
*
* @param array $params
* @param array $params The list of parameters.
*
* @return void
*
* @throws \Doctrine\DBAL\DBALException
*/
private static function _checkParams(array $params)
{
......
<?php
/*
* $Id$
*
* 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
......@@ -17,29 +15,30 @@
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
*/
namespace Doctrine\DBAL\Event;
use Doctrine\Common\EventArgs,
Doctrine\DBAL\Connection;
use Doctrine\Common\EventArgs;
use Doctrine\DBAL\Connection;
/**
* Event Arguments used when a Driver connection is established inside Doctrine\DBAL\Connection.
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.com
* @since 1.0
* @version $Revision$
* @author Benjamin Eberlei <kontakt@beberlei.de>
* @link www.doctrine-project.org
* @since 1.0
* @author Benjamin Eberlei <kontakt@beberlei.de>
*/
class ConnectionEventArgs extends EventArgs
{
/**
* @var Connection
* @var \Doctrine\DBAL\Connection
*/
private $_connection = null;
private $_connection;
/**
* @param \Doctrine\DBAL\Connection $connection
*/
public function __construct(Connection $connection)
{
$this->_connection = $connection;
......
......@@ -15,7 +15,7 @@
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
*/
namespace Doctrine\DBAL\Event\Listeners;
......@@ -24,32 +24,34 @@ use Doctrine\DBAL\Events;
use Doctrine\Common\EventSubscriber;
/**
* MySQL Session Init Event Subscriber which allows to set the Client Encoding of the Connection
* MySQL Session Init Event Subscriber which allows to set the Client Encoding of the Connection.
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.com
* @since 1.0
* @version $Revision$
* @author Benjamin Eberlei <kontakt@beberlei.de>
* @deprecated Use "charset" option to PDO MySQL Connection instead.
* @link www.doctrine-project.org
* @since 1.0
* @author Benjamin Eberlei <kontakt@beberlei.de>
* @deprecated Use "charset" option to PDO MySQL Connection instead.
*/
class MysqlSessionInit implements EventSubscriber
{
/**
* The charset.
*
* @var string
*/
private $_charset;
/**
* @var string
* The collation, or FALSE if no collation.
*
* @var string|boolean
*/
private $_collation;
/**
* Configure Charset and Collation options of MySQL Client for each Connection
* Configure Charset and Collation options of MySQL Client for each Connection.
*
* @param string $charset
* @param string $collation
* @param string $charset The charset.
* @param string|boolean $collation The collation, or FALSE if no collation.
*/
public function __construct($charset = 'utf8', $collation = false)
{
......@@ -58,7 +60,8 @@ class MysqlSessionInit implements EventSubscriber
}
/**
* @param ConnectionEventArgs $args
* @param \Doctrine\DBAL\Event\ConnectionEventArgs $args
*
* @return void
*/
public function postConnect(ConnectionEventArgs $args)
......@@ -67,6 +70,9 @@ class MysqlSessionInit implements EventSubscriber
$args->getConnection()->executeUpdate("SET NAMES ".$this->_charset . $collation);
}
/**
* {@inheritdoc}
*/
public function getSubscribedEvents()
{
return array(Events::postConnect);
......
......@@ -15,7 +15,7 @@
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
*/
namespace Doctrine\DBAL\Event\Listeners;
......@@ -33,13 +33,15 @@ use Doctrine\Common\EventSubscriber;
* NLS_TIMESTAMP_FORMAT="YYYY-MM-DD HH24:MI:SS"
* NLS_TIMESTAMP_TZ_FORMAT="YYYY-MM-DD HH24:MI:SS TZH:TZM"
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.com
* @since 2.0
* @author Benjamin Eberlei <kontakt@beberlei.de>
* @link www.doctrine-project.org
* @since 2.0
* @author Benjamin Eberlei <kontakt@beberlei.de>
*/
class OracleSessionInit implements EventSubscriber
{
/**
* @var array
*/
protected $_defaultSessionVars = array(
'NLS_TIME_FORMAT' => "HH24:MI:SS",
'NLS_DATE_FORMAT' => "YYYY-MM-DD HH24:MI:SS",
......@@ -57,7 +59,8 @@ class OracleSessionInit implements EventSubscriber
}
/**
* @param ConnectionEventArgs $args
* @param \Doctrine\DBAL\Event\ConnectionEventArgs $args
*
* @return void
*/
public function postConnect(ConnectionEventArgs $args)
......@@ -73,6 +76,9 @@ class OracleSessionInit implements EventSubscriber
}
}
/**
* {@inheritdoc}
*/
public function getSubscribedEvents()
{
return array(Events::postConnect);
......
......@@ -15,7 +15,7 @@
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
*/
namespace Doctrine\DBAL\Event\Listeners;
......@@ -26,10 +26,9 @@ use Doctrine\Common\EventSubscriber;
/**
* Session init listener for executing a single SQL statement right after a connection is opened.
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.com
* @since 2.2
* @author Benjamin Eberlei <kontakt@beberlei.de>
* @link www.doctrine-project.org
* @since 2.2
* @author Benjamin Eberlei <kontakt@beberlei.de>
*/
class SQLSessionInit implements EventSubscriber
{
......@@ -47,7 +46,8 @@ class SQLSessionInit implements EventSubscriber
}
/**
* @param ConnectionEventArgs $args
* @param \Doctrine\DBAL\Event\ConnectionEventArgs $args
*
* @return void
*/
public function postConnect(ConnectionEventArgs $args)
......@@ -56,6 +56,9 @@ class SQLSessionInit implements EventSubscriber
$conn->exec($this->sql);
}
/**
* {@inheritdoc}
*/
public function getSubscribedEvents()
{
return array(Events::postConnect);
......
......@@ -15,38 +15,37 @@
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
*/
namespace Doctrine\DBAL\Event;
use Doctrine\DBAL\Platforms\AbstractPlatform,
Doctrine\DBAL\Schema\Column,
Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Schema\TableDiff;
/**
* Event Arguments used when SQL queries for adding table columns are generated inside Doctrine\DBAL\Platform\*Platform.
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.com
* @since 2.2
* @author Jan Sorgalla <jsorgalla@googlemail.com>
* @link www.doctrine-project.org
* @since 2.2
* @author Jan Sorgalla <jsorgalla@googlemail.com>
*/
class SchemaAlterTableAddColumnEventArgs extends SchemaEventArgs
{
/**
* @var \Doctrine\DBAL\Schema\Column
*/
private $_column = null;
private $_column;
/**
* @var \Doctrine\DBAL\Schema\TableDiff
*/
private $_tableDiff = null;
private $_tableDiff;
/**
* @var \Doctrine\DBAL\Platforms\AbstractPlatform
*/
private $_platform = null;
private $_platform;
/**
* @var array
......@@ -54,8 +53,8 @@ class SchemaAlterTableAddColumnEventArgs extends SchemaEventArgs
private $_sql = array();
/**
* @param \Doctrine\DBAL\Schema\Column $column
* @param \Doctrine\DBAL\Schema\TableDiff $tableDiff
* @param \Doctrine\DBAL\Schema\Column $column
* @param \Doctrine\DBAL\Schema\TableDiff $tableDiff
* @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform
*/
public function __construct(Column $column, TableDiff $tableDiff, AbstractPlatform $platform)
......@@ -91,6 +90,7 @@ class SchemaAlterTableAddColumnEventArgs extends SchemaEventArgs
/**
* @param string|array $sql
*
* @return \Doctrine\DBAL\Event\SchemaAlterTableAddColumnEventArgs
*/
public function addSql($sql)
......
......@@ -15,38 +15,37 @@
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
*/
namespace Doctrine\DBAL\Event;
use Doctrine\DBAL\Platforms\AbstractPlatform,
Doctrine\DBAL\Schema\ColumnDiff,
Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Schema\ColumnDiff;
use Doctrine\DBAL\Schema\TableDiff;
/**
* Event Arguments used when SQL queries for changing table columns are generated inside Doctrine\DBAL\Platform\*Platform.
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.com
* @since 2.2
* @author Jan Sorgalla <jsorgalla@googlemail.com>
* @link www.doctrine-project.org
* @since 2.2
* @author Jan Sorgalla <jsorgalla@googlemail.com>
*/
class SchemaAlterTableChangeColumnEventArgs extends SchemaEventArgs
{
/**
* @var \Doctrine\DBAL\Schema\ColumnDiff
*/
private $_columnDiff = null;
private $_columnDiff;
/**
* @var \Doctrine\DBAL\Schema\TableDiff
*/
private $_tableDiff = null;
private $_tableDiff;
/**
* @var \Doctrine\DBAL\Platforms\AbstractPlatform
*/
private $_platform = null;
private $_platform;
/**
* @var array
......@@ -54,8 +53,8 @@ class SchemaAlterTableChangeColumnEventArgs extends SchemaEventArgs
private $_sql = array();
/**
* @param \Doctrine\DBAL\Schema\ColumnDiff $columnDiff
* @param \Doctrine\DBAL\Schema\TableDiff $tableDiff
* @param \Doctrine\DBAL\Schema\ColumnDiff $columnDiff
* @param \Doctrine\DBAL\Schema\TableDiff $tableDiff
* @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform
*/
public function __construct(ColumnDiff $columnDiff, TableDiff $tableDiff, AbstractPlatform $platform)
......@@ -91,6 +90,7 @@ class SchemaAlterTableChangeColumnEventArgs extends SchemaEventArgs
/**
* @param string|array $sql
*
* @return \Doctrine\DBAL\Event\SchemaAlterTableChangeColumnEventArgs
*/
public function addSql($sql)
......
......@@ -15,33 +15,31 @@
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
*/
namespace Doctrine\DBAL\Event;
use Doctrine\DBAL\Platforms\AbstractPlatform,
Doctrine\DBAL\Schema\Column,
Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Schema\TableDiff;
/**
* Event Arguments used when SQL queries for creating tables are generated inside Doctrine\DBAL\Platform\*Platform.
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.com
* @since 2.2
* @author Jan Sorgalla <jsorgalla@googlemail.com>
* @link www.doctrine-project.org
* @since 2.2
* @author Jan Sorgalla <jsorgalla@googlemail.com>
*/
class SchemaAlterTableEventArgs extends SchemaEventArgs
{
/**
* @var \Doctrine\DBAL\Schema\TableDiff
*/
private $_tableDiff = null;
private $_tableDiff;
/**
* @var \Doctrine\DBAL\Platforms\AbstractPlatform
*/
private $_platform = null;
private $_platform;
/**
* @var array
......@@ -49,7 +47,7 @@ class SchemaAlterTableEventArgs extends SchemaEventArgs
private $_sql = array();
/**
* @param \Doctrine\DBAL\Schema\TableDiff $tableDiff
* @param \Doctrine\DBAL\Schema\TableDiff $tableDiff
* @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform
*/
public function __construct(TableDiff $tableDiff, AbstractPlatform $platform)
......@@ -76,6 +74,7 @@ class SchemaAlterTableEventArgs extends SchemaEventArgs
/**
* @param string|array $sql
*
* @return \Doctrine\DBAL\Event\SchemaAlterTableEventArgs
*/
public function addSql($sql)
......
......@@ -15,38 +15,37 @@
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
*/
namespace Doctrine\DBAL\Event;
use Doctrine\DBAL\Platforms\AbstractPlatform,
Doctrine\DBAL\Schema\Column,
Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Schema\TableDiff;
/**
* Event Arguments used when SQL queries for removing table columns are generated inside Doctrine\DBAL\Platform\*Platform.
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.com
* @since 2.2
* @author Jan Sorgalla <jsorgalla@googlemail.com>
* @link www.doctrine-project.org
* @since 2.2
* @author Jan Sorgalla <jsorgalla@googlemail.com>
*/
class SchemaAlterTableRemoveColumnEventArgs extends SchemaEventArgs
{
/**
* @var \Doctrine\DBAL\Schema\Column
*/
private $_column = null;
private $_column;
/**
* @var \Doctrine\DBAL\Schema\TableDiff
*/
private $_tableDiff = null;
private $_tableDiff;
/**
* @var \Doctrine\DBAL\Platforms\AbstractPlatform
*/
private $_platform = null;
private $_platform;
/**
* @var array
......@@ -54,8 +53,8 @@ class SchemaAlterTableRemoveColumnEventArgs extends SchemaEventArgs
private $_sql = array();
/**
* @param \Doctrine\DBAL\Schema\Column $column
* @param \Doctrine\DBAL\Schema\TableDiff $tableDiff
* @param \Doctrine\DBAL\Schema\Column $column
* @param \Doctrine\DBAL\Schema\TableDiff $tableDiff
* @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform
*/
public function __construct(Column $column, TableDiff $tableDiff, AbstractPlatform $platform)
......@@ -91,6 +90,7 @@ class SchemaAlterTableRemoveColumnEventArgs extends SchemaEventArgs
/**
* @param string|array $sql
*
* @return \Doctrine\DBAL\Event\SchemaAlterTableRemoveColumnEventArgs
*/
public function addSql($sql)
......
......@@ -15,43 +15,42 @@
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
*/
namespace Doctrine\DBAL\Event;
use Doctrine\DBAL\Platforms\AbstractPlatform,
Doctrine\DBAL\Schema\Column,
Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Schema\TableDiff;
/**
* Event Arguments used when SQL queries for renaming table columns are generated inside Doctrine\DBAL\Platform\*Platform.
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.com
* @since 2.2
* @author Jan Sorgalla <jsorgalla@googlemail.com>
* @link www.doctrine-project.org
* @since 2.2
* @author Jan Sorgalla <jsorgalla@googlemail.com>
*/
class SchemaAlterTableRenameColumnEventArgs extends SchemaEventArgs
{
/**
* @var string
*/
private $_oldColumnName = null;
private $_oldColumnName;
/**
* @var \Doctrine\DBAL\Schema\Column
*/
private $_column = null;
private $_column;
/**
* @var \Doctrine\DBAL\Schema\TableDiff
*/
private $_tableDiff = null;
private $_tableDiff;
/**
* @var \Doctrine\DBAL\Platforms\AbstractPlatform
*/
private $_platform = null;
private $_platform;
/**
* @var array
......@@ -59,9 +58,9 @@ class SchemaAlterTableRenameColumnEventArgs extends SchemaEventArgs
private $_sql = array();
/**
* @param string $oldColumnName
* @param \Doctrine\DBAL\Schema\Column $column
* @param \Doctrine\DBAL\Schema\TableDiff $tableDiff
* @param string $oldColumnName
* @param \Doctrine\DBAL\Schema\Column $column
* @param \Doctrine\DBAL\Schema\TableDiff $tableDiff
* @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform
*/
public function __construct($oldColumnName, Column $column, TableDiff $tableDiff, AbstractPlatform $platform)
......@@ -106,6 +105,7 @@ class SchemaAlterTableRenameColumnEventArgs extends SchemaEventArgs
/**
* @param string|array $sql
*
* @return \Doctrine\DBAL\Event\SchemaAlterTableRenameColumnEventArgs
*/
public function addSql($sql)
......
......@@ -15,55 +15,54 @@
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
*/
namespace Doctrine\DBAL\Event;
use Doctrine\DBAL\Connection,
Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Schema\Column;
/**
* Event Arguments used when the portable column definition is generated inside Doctrine\DBAL\Schema\AbstractSchemaManager.
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.com
* @since 2.2
* @author Jan Sorgalla <jsorgalla@googlemail.com>
* @link www.doctrine-project.org
* @since 2.2
* @author Jan Sorgalla <jsorgalla@googlemail.com>
*/
class SchemaColumnDefinitionEventArgs extends SchemaEventArgs
{
/**
* @var \Doctrine\DBAL\Schema\Column
* @var \Doctrine\DBAL\Schema\Column|null
*/
private $_column = null;
/**
* Raw column data as fetched from the database
* Raw column data as fetched from the database.
*
* @var array
*/
private $_tableColumn = null;
private $_tableColumn;
/**
* @var string
*/
private $_table = null;
private $_table;
/**
* @var string
*/
private $_database = null;
private $_database;
/**
* @var \Doctrine\DBAL\Connection
*/
private $_connection = null;
private $_connection;
/**
* @param array $tableColumn
* @param string $table
* @param string $database
* @param \Doctrine\DBAL\Connection $conn
* @param array $tableColumn
* @param string $table
* @param string $database
* @param \Doctrine\DBAL\Connection $connection
*/
public function __construct(array $tableColumn, $table, $database, Connection $connection)
{
......@@ -78,7 +77,8 @@ class SchemaColumnDefinitionEventArgs extends SchemaEventArgs
* tables column list.
*
* @param null|\Doctrine\DBAL\Schema\Column $column
* @return SchemaColumnDefinitionEventArgs
*
* @return \Doctrine\DBAL\Event\SchemaColumnDefinitionEventArgs
*/
public function setColumn(Column $column = null)
{
......@@ -88,7 +88,7 @@ class SchemaColumnDefinitionEventArgs extends SchemaEventArgs
}
/**
* @return \Doctrine\DBAL\Schema\Column
* @return \Doctrine\DBAL\Schema\Column|null
*/
public function getColumn()
{
......
......@@ -15,38 +15,37 @@
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
*/
namespace Doctrine\DBAL\Event;
use Doctrine\DBAL\Platforms\AbstractPlatform,
Doctrine\DBAL\Schema\Column,
Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Schema\Table;
/**
* Event Arguments used when SQL queries for creating table columns are generated inside Doctrine\DBAL\Platform\AbstractPlatform.
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.com
* @since 2.2
* @author Jan Sorgalla <jsorgalla@googlemail.com>
* @link www.doctrine-project.org
* @since 2.2
* @author Jan Sorgalla <jsorgalla@googlemail.com>
*/
class SchemaCreateTableColumnEventArgs extends SchemaEventArgs
{
/**
* @var \Doctrine\DBAL\Schema\Column
*/
private $_column = null;
private $_column;
/**
* @var \Doctrine\DBAL\Schema\Table
*/
private $_table = null;
private $_table;
/**
* @var \Doctrine\DBAL\Platforms\AbstractPlatform
*/
private $_platform = null;
private $_platform;
/**
* @var array
......@@ -54,8 +53,8 @@ class SchemaCreateTableColumnEventArgs extends SchemaEventArgs
private $_sql = array();
/**
* @param \Doctrine\DBAL\Schema\Column $column
* @param \Doctrine\DBAL\Schema\Table $table
* @param \Doctrine\DBAL\Schema\Column $column
* @param \Doctrine\DBAL\Schema\Table $table
* @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform
*/
public function __construct(Column $column, Table $table, AbstractPlatform $platform)
......@@ -91,6 +90,7 @@ class SchemaCreateTableColumnEventArgs extends SchemaEventArgs
/**
* @param string|array $sql
*
* @return \Doctrine\DBAL\Event\SchemaCreateTableColumnEventArgs
*/
public function addSql($sql)
......
......@@ -15,42 +15,41 @@
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
*/
namespace Doctrine\DBAL\Event;
use Doctrine\DBAL\Platforms\AbstractPlatform,
Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Schema\Table;
/**
* Event Arguments used when SQL queries for creating tables are generated inside Doctrine\DBAL\Platform\AbstractPlatform.
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.com
* @since 2.2
* @author Jan Sorgalla <jsorgalla@googlemail.com>
* @link www.doctrine-project.org
* @since 2.2
* @author Jan Sorgalla <jsorgalla@googlemail.com>
*/
class SchemaCreateTableEventArgs extends SchemaEventArgs
{
/**
* @var \Doctrine\DBAL\Schema\Table
*/
private $_table = null;
private $_table;
/**
* @var array
*/
private $_columns = null;
private $_columns;
/**
* @var array
*/
private $_options = null;
private $_options;
/**
* @var \Doctrine\DBAL\Platforms\AbstractPlatform
*/
private $_platform = null;
private $_platform;
/**
* @var array
......@@ -58,9 +57,9 @@ class SchemaCreateTableEventArgs extends SchemaEventArgs
private $_sql = array();
/**
* @param \Doctrine\DBAL\Schema\Table $table
* @param array $columns
* @param array $options
* @param \Doctrine\DBAL\Schema\Table $table
* @param array $columns
* @param array $options
* @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform
*/
public function __construct(Table $table, array $columns, array $options, AbstractPlatform $platform)
......@@ -105,6 +104,7 @@ class SchemaCreateTableEventArgs extends SchemaEventArgs
/**
* @param string|array $sql
*
* @return \Doctrine\DBAL\Event\SchemaCreateTableEventArgs
*/
public function addSql($sql)
......
......@@ -15,41 +15,42 @@
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
*/
namespace Doctrine\DBAL\Event;
use Doctrine\DBAL\Platforms\AbstractPlatform,
Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Schema\Table;
/**
* Event Arguments used when the SQL query for dropping tables are generated inside Doctrine\DBAL\Platform\AbstractPlatform.
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.com
* @since 2.2
* @author Jan Sorgalla <jsorgalla@googlemail.com>
* @link www.doctrine-project.org
* @since 2.2
* @author Jan Sorgalla <jsorgalla@googlemail.com>
*/
class SchemaDropTableEventArgs extends SchemaEventArgs
{
/**
* @var string|\Doctrine\DBAL\Schema\Table
*/
private $_table = null;
private $_table;
/**
* @var \Doctrine\DBAL\Platforms\AbstractPlatform
*/
private $_platform = null;
private $_platform;
/**
* @var string
* @var string|null
*/
private $_sql = null;
/**
* @param string|\Doctrine\DBAL\Schema\Table $table
* @param string|\Doctrine\DBAL\Schema\Table $table
* @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform
*
* @throws \InvalidArgumentException
*/
public function __construct($table, AbstractPlatform $platform)
{
......@@ -79,6 +80,7 @@ class SchemaDropTableEventArgs extends SchemaEventArgs
/**
* @param string $sql
*
* @return \Doctrine\DBAL\Event\SchemaDropTableEventArgs
*/
public function setSql($sql)
......@@ -89,7 +91,7 @@ class SchemaDropTableEventArgs extends SchemaEventArgs
}
/**
* @return string
* @return string|null
*/
public function getSql()
{
......
......@@ -15,7 +15,7 @@
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
*/
namespace Doctrine\DBAL\Event;
......@@ -24,10 +24,9 @@ use Doctrine\Common\EventArgs;
/**
* Base class for schema related events.
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.com
* @since 2.2
* @author Jan Sorgalla <jsorgalla@googlemail.com>
* @link www.doctrine-project.org
* @since 2.2
* @author Jan Sorgalla <jsorgalla@googlemail.com>
*/
class SchemaEventArgs extends EventArgs
{
......
......@@ -15,49 +15,48 @@
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
*/
namespace Doctrine\DBAL\Event;
use Doctrine\DBAL\Connection,
Doctrine\DBAL\Schema\Index;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Schema\Index;
/**
* Event Arguments used when the portable index definition is generated inside Doctrine\DBAL\Schema\AbstractSchemaManager.
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.com
* @since 2.2
* @author Jan Sorgalla <jsorgalla@googlemail.com>
* @link www.doctrine-project.org
* @since 2.2
* @author Jan Sorgalla <jsorgalla@googlemail.com>
*/
class SchemaIndexDefinitionEventArgs extends SchemaEventArgs
{
/**
* @var \Doctrine\DBAL\Schema\Index
* @var \Doctrine\DBAL\Schema\Index|null
*/
private $_index = null;
/**
* Raw index data as fetched from the database
* Raw index data as fetched from the database.
*
* @var array
*/
private $_tableIndex = null;
private $_tableIndex;
/**
* @var string
*/
private $_table = null;
private $_table;
/**
* @var \Doctrine\DBAL\Connection
*/
private $_connection = null;
private $_connection;
/**
* @param array $tableIndex
* @param string $table
* @param \Doctrine\DBAL\Connection $conn
* @param array $tableIndex
* @param string $table
* @param \Doctrine\DBAL\Connection $connection
*/
public function __construct(array $tableIndex, $table, Connection $connection)
{
......@@ -67,10 +66,10 @@ class SchemaIndexDefinitionEventArgs extends SchemaEventArgs
}
/**
* Allows to clear the index which means the index will be excluded from
* tables index list.
* Allows to clear the index which means the index will be excluded from tables index list.
*
* @param null|\Doctrine\DBAL\Schema\Index $index
*
* @return SchemaIndexDefinitionEventArgs
*/
public function setIndex(Index $index = null)
......@@ -81,7 +80,7 @@ class SchemaIndexDefinitionEventArgs extends SchemaEventArgs
}
/**
* @return \Doctrine\DBAL\Schema\Index
* @return \Doctrine\DBAL\Schema\Index|null
*/
public function getIndex()
{
......
<?php
/*
* $Id$
*
* 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
......@@ -31,7 +29,12 @@ namespace Doctrine\DBAL;
*/
final class Events
{
private function __construct() {}
/**
* Private constructor. This class cannot be instantiated.
*/
private function __construct()
{
}
const postConnect = 'postConnect';
......
......@@ -79,8 +79,10 @@ class TableGenerator
private $sequences = array();
/**
* @param Connection $conn
* @param string $generatorTableName
* @param \Doctrine\DBAL\Connection $conn
* @param string $generatorTableName
*
* @throws \Doctrine\DBAL\DBALException
*/
public function __construct(Connection $conn, $generatorTableName = 'sequences')
{
......@@ -93,10 +95,13 @@ class TableGenerator
}
/**
* Generate the next unused value for the given sequence name
* Generates the next unused value for the given sequence name.
*
* @param string $sequenceName
*
* @return integer
*
* @param string
* @return int
* @throws \Doctrine\DBAL\DBALException
*/
public function nextValue($sequenceName)
{
......@@ -106,6 +111,7 @@ class TableGenerator
if ($this->sequences[$sequenceName]['value'] >= $this->sequences[$sequenceName]['max']) {
unset ($this->sequences[$sequenceName]);
}
return $value;
}
......@@ -157,4 +163,3 @@ class TableGenerator
return $value;
}
}
......@@ -19,13 +19,12 @@
namespace Doctrine\DBAL\Id;
use Doctrine\DBAL\Schema\Table,
Doctrine\DBAL\Schema\Schema,
Doctrine\DBAL\Schema\Column,
Doctrine\DBAL\Schema\ForeignKeyConstraint,
Doctrine\DBAL\Schema\Constraint,
Doctrine\DBAL\Schema\Sequence,
Doctrine\DBAL\Schema\Index;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Schema\ForeignKeyConstraint;
use Doctrine\DBAL\Schema\Sequence;
use Doctrine\DBAL\Schema\Index;
class TableGeneratorSchemaVisitor implements \Doctrine\DBAL\Schema\Visitor\Visitor
{
......@@ -34,13 +33,16 @@ class TableGeneratorSchemaVisitor implements \Doctrine\DBAL\Schema\Visitor\Visit
*/
private $generatorTableName;
/**
* @param string $generatorTableName
*/
public function __construct($generatorTableName = 'sequences')
{
$this->generatorTableName = $generatorTableName;
}
/**
* @param Schema $schema
* {@inheritdoc}
*/
public function acceptSchema(Schema $schema)
{
......@@ -51,40 +53,37 @@ class TableGeneratorSchemaVisitor implements \Doctrine\DBAL\Schema\Visitor\Visit
}
/**
* @param Table $table
* {@inheritdoc}
*/
public function acceptTable(Table $table)
{
}
/**
* @param Column $column
* {@inheritdoc}
*/
public function acceptColumn(Table $table, Column $column)
{
}
/**
* @param Table $localTable
* @param ForeignKeyConstraint $fkConstraint
* {@inheritdoc}
*/
public function acceptForeignKey(Table $localTable, ForeignKeyConstraint $fkConstraint)
{
}
/**
* @param Table $table
* @param Index $index
* {@inheritdoc}
*/
public function acceptIndex(Table $table, Index $index)
{
}
/**
* @param Sequence $sequence
* {@inheritdoc}
*/
public function acceptSequence(Sequence $sequence)
{
}
}
<?php
/*
* $Id$
*
* 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
......@@ -17,19 +15,17 @@
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
*/
namespace Doctrine\DBAL;
/**
* Contains all DBAL LockModes
* Contains all DBAL LockModes.
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.com
* @since 1.0
* @version $Revision$
* @author Benjamin Eberlei <kontakt@beberlei.de>
* @author Roman Borschel <roman@code-factory.org>
* @link www.doctrine-project.org
* @since 1.0
* @author Benjamin Eberlei <kontakt@beberlei.de>
* @author Roman Borschel <roman@code-factory.org>
*/
class LockMode
{
......@@ -38,5 +34,10 @@ class LockMode
const PESSIMISTIC_READ = 2;
const PESSIMISTIC_WRITE = 4;
final private function __construct() { }
/**
* Private constructor. This class cannot be instantiated.
*/
final private function __construct()
{
}
}
<?php
/*
* $Id$
*
* 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
......@@ -22,27 +20,39 @@
namespace Doctrine\DBAL\Logging;
/**
* Includes executed SQLs in a Debug Stack
* Includes executed SQLs in a Debug Stack.
*
*
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision$
* @author Benjamin Eberlei <kontakt@beberlei.de>
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
* @link www.doctrine-project.org
* @since 2.0
* @author Benjamin Eberlei <kontakt@beberlei.de>
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
class DebugStack implements SQLLogger
{
/** @var array $queries Executed SQL queries. */
/**
* Executed SQL queries.
*
* @var array
*/
public $queries = array();
/** @var boolean $enabled If Debug Stack is enabled (log queries) or not. */
/**
* If Debug Stack is enabled (log queries) or not.
*
* @var boolean
*/
public $enabled = true;
/**
* @var float|null
*/
public $start = null;
/**
* @var integer
*/
public $currentQuery = 0;
/**
......@@ -66,4 +76,3 @@ class DebugStack implements SQLLogger
}
}
}
<?php
/*
* $Id$
*
* 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
......@@ -24,14 +22,12 @@ namespace Doctrine\DBAL\Logging;
/**
* A SQL logger that logs to the standard output using echo/var_dump.
*
*
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision$
* @author Benjamin Eberlei <kontakt@beberlei.de>
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
* @link www.doctrine-project.org
* @since 2.0
* @author Benjamin Eberlei <kontakt@beberlei.de>
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
class EchoSQLLogger implements SQLLogger
{
......@@ -56,6 +52,5 @@ class EchoSQLLogger implements SQLLogger
*/
public function stopQuery()
{
}
}
......@@ -20,21 +20,25 @@
namespace Doctrine\DBAL\Logging;
/**
* Chains multiple SQLLogger
* Chains multiple SQLLogger.
*
*
* @link www.doctrine-project.org
* @since 2.2
* @author Christophe Coevoet <stof@notk.org>
* @link www.doctrine-project.org
* @since 2.2
* @author Christophe Coevoet <stof@notk.org>
*/
class LoggerChain implements SQLLogger
{
/**
* @var \Doctrine\DBAL\Logging\SQLLogger[]
*/
private $loggers = array();
/**
* Adds a logger in the chain
* Adds a logger in the chain.
*
* @param SQLLogger $logger
* @param \Doctrine\DBAL\Logging\SQLLogger $logger
*
* @return void
*/
public function addLogger(SQLLogger $logger)
{
......@@ -61,4 +65,3 @@ class LoggerChain implements SQLLogger
}
}
}
<?php
/*
* $Id$
*
* 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
......@@ -24,29 +22,28 @@ namespace Doctrine\DBAL\Logging;
/**
* Interface for SQL loggers.
*
*
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision$
* @author Benjamin Eberlei <kontakt@beberlei.de>
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
* @link www.doctrine-project.org
* @since 2.0
* @author Benjamin Eberlei <kontakt@beberlei.de>
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
interface SQLLogger
{
/**
* Logs a SQL statement somewhere.
*
* @param string $sql The SQL to be executed.
* @param array $params The SQL parameters.
* @param array $types The SQL parameter types.
* @param string $sql The SQL to be executed.
* @param array|null $params The SQL parameters.
* @param array|null $types The SQL parameter types.
*
* @return void
*/
public function startQuery($sql, array $params = null, array $types = null);
/**
* Mark the last started query as stopped. This can be used for timing of queries.
* Marks the last started query as stopped. This can be used for timing of queries.
*
* @return void
*/
......
......@@ -15,7 +15,7 @@
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
*/
namespace Doctrine\DBAL\Platforms;
......@@ -153,16 +153,25 @@ class DB2Platform extends AbstractPlatform
return 'TIME';
}
/**
* {@inheritDoc}
*/
public function getListDatabasesSQL()
{
throw DBALException::notSupported(__METHOD__);
}
/**
* {@inheritDoc}
*/
public function getListSequencesSQL($database)
{
throw DBALException::notSupported(__METHOD__);
}
/**
* {@inheritDoc}
*/
public function getListTableConstraintsSQL($table)
{
throw DBALException::notSupported(__METHOD__);
......@@ -172,8 +181,10 @@ class DB2Platform extends AbstractPlatform
* This code fragment is originally from the Zend_Db_Adapter_Db2 class.
*
* @license New BSD License
* @param string $table
*
* @param string $table
* @param string $database
*
* @return string
*/
public function getListTableColumnsSQL($table, $database = null)
......@@ -192,11 +203,17 @@ class DB2Platform extends AbstractPlatform
WHERE UPPER(c.tabname) = UPPER('" . $table . "') ORDER BY c.colno";
}
/**
* {@inheritDoc}
*/
public function getListTablesSQL()
{
return "SELECT NAME FROM SYSIBM.SYSTABLES WHERE TYPE = 'T'";
}
/**
* {@inheritDoc}
*/
public function getListUsersSQL()
{
throw DBALException::notSupported(__METHOD__);
......@@ -218,17 +235,26 @@ class DB2Platform extends AbstractPlatform
return "SELECT NAME, COLNAMES, UNIQUERULE FROM SYSIBM.SYSINDEXES WHERE TBNAME = UPPER('" . $table . "')";
}
/**
* {@inheritDoc}
*/
public function getListTableForeignKeysSQL($table)
{
return "SELECT TBNAME, RELNAME, REFTBNAME, DELETERULE, UPDATERULE, FKCOLNAMES, PKCOLNAMES ".
"FROM SYSIBM.SYSRELS WHERE TBNAME = UPPER('".$table."')";
}
/**
* {@inheritDoc}
*/
public function getCreateViewSQL($name, $sql)
{
return "CREATE VIEW ".$name." AS ".$sql;
}
/**
* {@inheritDoc}
*/
public function getDropViewSQL($name)
{
return "DROP VIEW ".$name;
......@@ -242,6 +268,9 @@ class DB2Platform extends AbstractPlatform
throw DBALException::notSupported(__METHOD__);
}
/**
* {@inheritDoc}
*/
public function getSequenceNextValSQL($sequenceName)
{
throw DBALException::notSupported(__METHOD__);
......@@ -428,6 +457,9 @@ class DB2Platform extends AbstractPlatform
return 'INSERT INTO ' . $tableName . ' (' . $identifierColumnName . ') VALUES (DEFAULT)';
}
/**
* {@inheritDoc}
*/
public function getCreateTemporaryTableSnippetSQL()
{
return "DECLARE GLOBAL TEMPORARY TABLE";
......@@ -510,6 +542,9 @@ class DB2Platform extends AbstractPlatform
return strtoupper($column);
}
/**
* {@inheritDoc}
*/
public function getForUpdateSQL()
{
return ' WITH RR USE AND KEEP UPDATE LOCKS';
......
......@@ -17,21 +17,26 @@
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\DBAL\Platforms\Keywords;
/**
* Drizzle Keywordlist
* Drizzle Keywordlist.
*
* @author Kim Hemsø Rasmussen <kimhemsoe@gmail.com>
*/
class DrizzleKeywords extends KeywordList
{
/**
* {@inheritdoc}
*/
public function getName()
{
return 'drizzle';
}
/**
* {@inheritdoc}
*/
protected function getKeywords()
{
return array(
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment