0

在我的模型函数中,我有一个这样的查询:

   function update_single($table,$data=array(),$id)
   {
            if($id!=0)
            {
                $this->db->trans_start()
                         ->where('id',$id)
                         ->update($table,$data)
                         ->trans_complete();
                return TRUE;

            }
            else
            {
                return FALSE;
            }
   }

我收到错误消息

Fatal error: Call to a member function where() on a non-object in   /Applications/MAMP/htdocs/asset/application/models/history/history_model.php on line 1149
4

1 回答 1

1

根据 codeigniter API,trans_start 和 trans_complete 函数不返回数据库对象,因此链接不起作用,您必须将它们的调用分开。

$this->db->trans_start();
$this->db->where('id',$id)
         ->update($table,$data);
$this->db->trans_complete();
于 2013-07-17T05:32:17.153 回答