$transaction = Yii::app()->db->beginTransaction();
try {
$transaction=$connection->beginTransaction();
$model = new UserRole();
$model->role_name="new";
$model->save();
$transaction->commit();
Yii::log('Done', 'trace', 'stripe');
}
catch (Exception $e) {
$transaction->rollback();
}
Why dataâs are insert in db after that begintransaction in yii,What is $connection?i dont exactly what is meaning of $connection. In My config.php My Db connection like below.
âdbâ => require(dirname(FILE) . â/database.phpâ),
$connection = array(
âconnectionStringâ => âmysql:host=localhost;dbname=xxxâ,
âusernameâ => ârootâ,
âpasswordâ => ââ,
âcharsetâ => âutf8â,
âemulatePrepareâ => true,
âtablePrefixâ => âtbl_â,
);
My databse connection in another file database.php
I got error like,
Call to a member function beginTransaction() on a non-object.
Why dataâs are not insert after that beginTransaction?