Hi there!
Here is my code:
$transaction=Yii::app()->db->beginTransaction();
$code=0;
$success=true;
try
{
$file->save();
}catch (Exception $e) {
$code=$e->getCode();
}
if ($code==0||$code==23505)
{
$cleanContract=Yii::app()->db->createCommand(
"DELETE FROM contract"
)->query();
}
else
{
report_error("Error when saving file $path");
$success = false;
}
if($success)
$transaction->commit();
else
{
$transaction->rollback();
}
return $success;
When I try to execute query cleancontract, or any other query, I get CDbException "In failed sql transaction" when my $file->save() return code 23505. In fact, I think I must handle exception with code 23505 in order to execute my second query, cleancontract, without catch this exception.
How could i do this?
Thanks!