Hi all,
I want to create/update… both file name and correspoding record in DB. can I use transaction? I tried this:
$transaction=$model->dbConnection->beginTransaction();
try{
//create a row entry
$model->save();
//create a pysical folder
mkdir(Yii::app()->params['fileRoot'].$model->name);
$transaction->commit();
echo $model->id;
}
catch(Exception $e){
$transaction->rollBack();
echo '-1';
}
but it seems no effect, because when the fileRoot was incorrect, it still prints out $model->id.
thanks for reading this.