使用Yii :: app()结束交易 - >结束

时间:2017-02-21 11:53:58

标签: yii yii2

yii 1

Mysql Innodb交易还会在Yii :: app() - > end()之后结束吗? 这里基于模型验证,错误被返回到javascript:

    begin transaction

    if (!$model->save()) {
       echo CJSON::encode(array(
                                "error"=>true,
                                "errorDetails" => $model->getErrors(),
                                "code"=>"500"
                    ));
       Yii::app()->end();
    }

   end transaction

我们是否可以在上述情况下找到Yii :: app()和结束实时交易的活动交易,因为否则将使交易保持打开状态

Yii::app()->onEndRequest = function($event){
    //Find active transaction for current request and db and rollback 
};

1 个答案:

答案 0 :(得分:1)

这在index.php中解决了它

> rbind.pages(lapply(all_fi[2:5], f.it))

============================  =========
file_name                     file_size
============================  =========
inst/data/yob1881/female.txt      16476
inst/data/yob1881/male.txt        15306
inst/data/yob1882/female.txt      18109
inst/data/yob1882/male.txt        16923
inst/data/yob1883/female.txt      18537
inst/data/yob1883/male.txt        15861
inst/data/yob1884/female.txt      20641
inst/data/yob1884/male.txt        17300
============================  =========