* @param string $savepoint name of a savepoint to release
* @param string $savepoint name of a savepoint to release
* @throws Doctrine_Transaction_Exception if the transaction fails at PDO level
* @throws Doctrine_Transaction_Exception if the transaction fails at PDO level
* @throws Doctrine_Validator_Exception if the transaction fails due to record validations
* @throws Doctrine_Validator_Exception if the transaction fails due to record validations
* @return boolean false if commit couldn't be performed, true otherwise
* @return boolean false if commit couldn't be performed, true otherwise
*/
*/
publicfunctioncommit($savepoint=null)
publicfunctioncommit()
{
{
return$this->_transaction->commit($savepoint);
if($this->_transactionNestingLevel==0){
thrownewDoctrine_Exception("Commit failed. There is no active transaction.");
}
$this->connect();
if($this->_transactionNestingLevel==1){
return$this->_pdo->commit();
}
--$this->_transactionNestingLevel;
returntrue;
}
}
/**
/**
...
@@ -964,73 +813,22 @@ abstract class Doctrine_Connection
...
@@ -964,73 +813,22 @@ abstract class Doctrine_Connection
* @throws Doctrine_Transaction_Exception If the rollback operation fails at database level.
* @throws Doctrine_Transaction_Exception If the rollback operation fails at database level.
* @return boolean FALSE if rollback couldn't be performed, TRUE otherwise.
* @return boolean FALSE if rollback couldn't be performed, TRUE otherwise.
*/
*/
publicfunctionrollback($savepoint=null)
publicfunctionrollback()
{
$this->_transaction->rollback($savepoint);
}
/**
* Creates the database for the connection instance.
*
* @return mixed Will return an instance of the exception thrown if the
* create database fails, otherwise it returns a string
* detailing the success.
*/
publicfunctioncreateDatabase()
{
{
try{
if($this->_transactionNestingLevel==0){
if(!$dsn=$this->getOption('dsn')){
thrownewDoctrine_Exception("Rollback failed. There is no active transaction.");
thrownewDoctrine_Connection_Exception('You must create your Doctrine_Connection by using a valid Doctrine style dsn in order to use the create/drop database functionality');
}
$manager=$this->getManager();
$info=$manager->parsePdoDsn($dsn);
$username=$this->getOption('username');
$password=$this->getOption('password');
// Make connection without database specified so we can create it
return'Successfully created database for connection "'.$this->getName().'" named "'.$info['dbname'].'"';
}catch(Exception$e){
return$e;
}
}
}
$this->connect();
/**
* Method for dropping the database for the connection instance
*
* @return mixed Will return an instance of the exception thrown if the drop
* database fails, otherwise it returns a string detailing the success.
*/
publicfunctiondropDatabase()
{
try{
if(!$dsn=$this->getOption('dsn')){
thrownewDoctrine_Connection_Exception('You must create your Doctrine_Connection by using a valid Doctrine style dsn in order to use the create/drop database functionality');
}
$info=$this->getManager()->parsePdoDsn($dsn);
$this->export->dropDatabase($info['dbname']);
return'Successfully dropped database for connection "'.$this->getName().'" named "'.$info['dbname'].'"';
if($this->_transactionNestingLevel==1){
}catch(Exception$e){
$this->_transactionNestingLevel=0;
return$e;
return$this->_pdo->rollback();
}
}
--$this->_transactionNestingLevel;
returntrue;
}
}
/**
/**
...
@@ -1048,19 +846,6 @@ abstract class Doctrine_Connection
...
@@ -1048,19 +846,6 @@ abstract class Doctrine_Connection
* @param integer $column The 0-indexed column in the result set.
*
* @return array Associative meta data array with the following structure:
*
* native_type The PHP native type used to represent the column value.
* driver:decl_ type The SQL type used to represent the column value in the database. If the column in the result set is the result of a function, this value is not returned by PDOStatement->getColumnMeta().
* flags Any flags set for this column.
* name The name of this column as returned by the database.
* len The length of this column. Normally -1 for types other than floating point decimals.
* precision The numeric precision of this column. Normally 0 for types other than floating point decimals.
* pdo_type The type of this column as represented by the PDO::PARAM_* constants.
*/
publicfunctiongetColumnMeta($column);
/**
* nextRowset
* Advances to the next rowset in a multi-rowset statement handle
*
* Some database servers support stored procedures that return more than one rowset
* (also known as a result set). The nextRowset() method enables you to access the second
* and subsequent rowsets associated with a PDOStatement object. Each rowset can have a
* different set of columns from the preceding rowset.
*
* @return boolean Returns TRUE on success or FALSE on failure.
*/
publicfunctionnextRowset();
/**
* rowCount
* rowCount() returns the number of rows affected by the last DELETE, INSERT, or UPDATE statement
* executed by the corresponding object.
*
* If the last SQL statement executed by the associated Statement object was a SELECT statement,
* some databases may return the number of rows returned by that statement. However,
* this behaviour is not guaranteed for all databases and should not be
* relied on for portable applications.
*
* @return integer Returns the number of rows.
*/
publicfunctionrowCount();
/**
* setAttribute
* Set a statement attribute
*
* @param integer $attribute
* @param mixed $value the value of given attribute
* @return boolean Returns TRUE on success or FALSE on failure.
*/
publicfunctionsetAttribute($attribute,$value);
/**
* setFetchMode
* Set the default fetch mode for this statement
*
* @param integer $mode The fetch mode must be one of the Doctrine::FETCH_* constants.
* @return boolean Returns 1 on success or FALSE on failure.