Codeigniter事务不适用于数据库切换概念

时间:2019-05-08 11:51:50

标签: php database codeigniter database-connection

我正在使用具有数据库切换概念的Codeigniter翻译

how to switch database in codeigniter https://www.codeigniter.com/user_guide/database/transactions.html

但是似乎没有用。

代码如下

$this->db->trans_start(); 
foreach ($all_db as $key => $value) {
        $result = $this->switch_database->switch_with_data($value,$staff_data->email);

        if(!empty($result->user)){
            $res = $this->staff->update_staff_info($user_info,$result->user->staffid);
        }
        if(!empty($result->clients)){
            $clients=array("firstname"=>$user_info["firstname"],"lastname"=>$user_info["lastname"],"phonenumber"=>$user_info["phonenumber"],"email"=>$user_info["email"],"is_primary"=>1);
            $res = $this->clients->update_contact($clients,$result->clients->id);
       }
} 
$success= $this->staff->update_profile($data, get_staff_user_id());
$this->db->trans_complete();
if ($this->db->trans_status() === FALSE){
    $this->db->trans_rollback();
}else{
    $this->db->trans_commit();
}

让我知道我是否也错了。

0 个答案:

没有答案