Hey :)
Is there a way to use a initiate transaction ? I mean, I got this:
class MyUsersClass
{
protected $objDb = null;
public function __construct()
{
$this->objDb = Zend_Registry::get( 'objDb' );
}
public function save( Array $arrData )
{
$this->objDb->beginTransaction();
try
{
// Try to insert the user groups.
foreach ( $arrUserGroups AS $intGroupIndex => $intGroupId )
{
$arrUserGroupsData = array( "user_id" => $lastInsertId,
"group_id" => $intGroupId );
self::saveUserGroups( $arrUserGroupsData );
}
$this->objDb->commit();
}
catch ( Exception $objException )
{
$this->objDb->rollBack();
}
}
public function saveUserGroups( Array $arrArguments )
{
if ( false !== empty( $arrArguments ) )
{
throw new Exception( "Data to save user groups can't be empty." );
}
if ( false !== empty( $arrArguments["user_id"] ) )
{
throw new Exception( "User id can't be empty." );
}
if ( false !== empty( $arrArguments["group_id"] ) )
{
throw new Exception( "Group id can't be empty." );
}
$this->objDb->beginTransaction();
try
{
// Insert data.
$this->objDb->insert( $this->strUserGroupsTable, $arrArguments );
$this->objDb->commit();
}
catch ( Exception $objException )
{
$this->objDb->rollBack();
throw new Exception( "Can't save user groups -
({$objException->getMessage()})" );
}
}
}
So I'm saving some user data into the save method, that method have a
transaction started, then I call the saveUserGroups method on the same class
and it have another
transaction started, is possible to, I don't know, get the transaction started
in the save method ? cause I got a fatal error that another transaction is
started.
Thx.