Skip to content

Commit

Permalink
Merge upstream into lock-support branch
Browse files Browse the repository at this point in the history
  • Loading branch information
beberlei committed May 15, 2010
2 parents c330388 + 3b01277 commit 64b57bb
Show file tree
Hide file tree
Showing 609 changed files with 1,367 additions and 90,664 deletions.
1 change: 1 addition & 0 deletions bin/doctrine.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
new \Doctrine\ORM\Tools\Console\Command\GenerateProxiesCommand(),
new \Doctrine\ORM\Tools\Console\Command\ConvertMappingCommand(),
new \Doctrine\ORM\Tools\Console\Command\RunDqlCommand(),
new \Doctrine\ORM\Tools\Console\Command\ValidateSchemaCommand(),

));
$cli->run();
2 changes: 1 addition & 1 deletion lib/Doctrine/Common/Annotations/AnnotationReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public function getMethodAnnotations(ReflectionMethod $method)
// Attempt to grab data from cache
if (($data = $this->_cache->fetch($cacheKey)) !== false) {
return $data;
}
}

$context = 'method ' . $method->getDeclaringClass()->getName() . '::' . $method->getName() . '()';
$annotations = $this->_parser->parse($method->getDocComment(), $context);
Expand Down
37 changes: 29 additions & 8 deletions lib/Doctrine/DBAL/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

namespace Doctrine\DBAL;

use PDO, Closure,
use PDO, Closure, Exception,
Doctrine\DBAL\Types\Type,
Doctrine\DBAL\Driver\Connection as DriverConnection,
Doctrine\Common\EventManager,
Expand Down Expand Up @@ -310,9 +310,8 @@ public function connect()
* @param string $statement The SQL query.
* @param array $params The query parameters.
* @return array
* @todo Rename: fetchAssoc
*/
public function fetchRow($statement, array $params = array())
public function fetchAssoc($statement, array $params = array())
{
return $this->executeQuery($statement, $params)->fetch(PDO::FETCH_ASSOC);
}
Expand Down Expand Up @@ -583,10 +582,10 @@ public function executeQuery($query, array $params = array(), $types = array())
* represents a row of the result set.
* @return mixed The projected result of the query.
*/
public function project($query, array $params = array(), Closure $function)
public function project($query, array $params, Closure $function)
{
$result = array();
$stmt = $this->executeQuery($query, $params);
$stmt = $this->executeQuery($query, $params ?: array());

while ($row = $stmt->fetch()) {
$result[] = $function($row);
Expand Down Expand Up @@ -706,6 +705,28 @@ public function lastInsertId($seqName = null)
return $this->_conn->lastInsertId($seqName);
}

/**
* Executes a function in a transaction.
*
* The function gets passed this Connection instance as an (optional) parameter.
*
* If an exception occurs during execution of the function or transaction commit,
* the transaction is rolled back and the exception re-thrown.
*
* @param Closure $func The function to execute transactionally.
*/
public function transactional(Closure $func)
{
$this->beginTransaction();
try {
$func($this);
$this->commit();
} catch (Exception $e) {
$this->rollback();
throw $e;
}
}

/**
* Starts a transaction by suspending auto-commit mode.
*
Expand Down Expand Up @@ -789,7 +810,7 @@ public function getWrappedConnection()
* Gets the SchemaManager that can be used to inspect or change the
* database schema through the connection.
*
* @return Doctrine\DBAL\Schema\AbstractSchemaManager
* @return Doctrine\DBAL\Schema\SchemaManager
*/
public function getSchemaManager()
{
Expand Down Expand Up @@ -820,7 +841,7 @@ public function setRollbackOnly()
* @return boolean
* @throws ConnectionException If no transaction is active.
*/
public function getRollbackOnly()
public function isRollbackOnly()
{
if ($this->_transactionNestingLevel == 0) {
throw ConnectionException::noActiveTransaction();
Expand Down Expand Up @@ -911,4 +932,4 @@ private function _bindTypedValues($stmt, array $params, array $types)
}
}
}
}
}
19 changes: 18 additions & 1 deletion lib/Doctrine/DBAL/Driver.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
<?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 LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/

namespace Doctrine\DBAL;

Expand Down Expand Up @@ -51,5 +68,5 @@ public function getName();
* @param Doctrine\DBAL\Connection $conn
* @return string $database
*/
public function getDatabase(\Doctrine\DBAL\Connection $conn);
public function getDatabase(Connection $conn);
}
2 changes: 0 additions & 2 deletions lib/Doctrine/DBAL/Driver/Connection.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?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
Expand Down
11 changes: 3 additions & 8 deletions lib/Doctrine/DBAL/Driver/IBMDB2/DB2Driver.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?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
Expand All @@ -25,13 +23,10 @@
Doctrine\DBAL\Connection;

/**
* IBM Db2 Driver
* IBM DB2 Driver
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.com
* @since 1.0
* @version $Revision$
* @author Benjamin Eberlei <[email protected]>
* @since 2.0
* @author Benjamin Eberlei <[email protected]>
*/
class DB2Driver implements Driver
{
Expand Down
29 changes: 17 additions & 12 deletions lib/Doctrine/DBAL/Driver/PDOMsSql/Connection.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?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
Expand All @@ -21,40 +19,47 @@

namespace Doctrine\DBAL\Driver\PDOMsSql;

use PDO, Doctrine\DBAL\Driver\Connection as DriverConnection;

/**
* MsSql Connection implementation.
*
* @since 2.0
*/
class Connection extends \PDO implements \Doctrine\DBAL\Driver\Connection
class Connection extends PDO implements DriverConnection
{
/**
* Performs the rollback.
*
* @override
* {@inheritdoc}
*/
public function rollback()
{
$this->exec('ROLLBACK TRANSACTION');
}

/**
* Performs the commit.
*
* @override
* {@inheritdoc}
*/
public function commit()
{
$this->exec('COMMIT TRANSACTION');
}

/**
* Begins a database transaction.
*
* @override
* {@inheritdoc}
*/
public function beginTransaction()
{
$this->exec('BEGIN TRANSACTION');
}

/**
* {@inheritdoc}
*/
public function lastInsertId($name = null)
{
$stmt = $this->query('SELECT SCOPE_IDENTITY()');
$id = $stmt->fetchColumn();
$stmt->closeCursor();
return $id;
}
}
2 changes: 0 additions & 2 deletions lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?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
Expand Down
2 changes: 0 additions & 2 deletions lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?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
Expand Down
2 changes: 0 additions & 2 deletions lib/Doctrine/DBAL/DriverManager.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?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
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -1901,4 +1901,4 @@ public function getTruncateTableSQL($tableName, $cascade = false)
{
return 'TRUNCATE '.$tableName;
}
}
}
6 changes: 3 additions & 3 deletions lib/Doctrine/DBAL/Types/IntegerType.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

/**
* Type that maps an SQL INT to a PHP integer.
*
*
* @author Roman Borschel <[email protected]>
* @since 2.0
*/
Expand All @@ -43,9 +43,9 @@ public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $pla

public function convertToPHPValue($value, AbstractPlatform $platform)
{
return (int) $value;
return (null === $value) ? null : (int) $value;
}

public function getBindingType()
{
return \PDO::PARAM_INT;
Expand Down
Loading

0 comments on commit 64b57bb

Please sign in to comment.