看过类似的问答,还是不知道,所以不要拍:)
我正在尝试这个:
Array ( [0] => Array ( [id] => 3 [paid_date] => 2013-06-25 20:37:35 [statement_status] => P ) [1] => Array ( [id] => 4 [paid_date] => 2013-06-25 20:37:35 [statement_status] => P ) )
$this->db->update_batch('credit_statement', $data, 'id');
并返回:
A Database Error Occurred
You must use the "set" method to update an entry.
并觉得我尊重 Codeigniter 书:
$data = array(
array(
'title' => 'My title' ,
'name' => 'My Name 2' ,
'date' => 'My date 2'
),
array(
'title' => 'Another title' ,
'name' => 'Another Name 2' ,
'date' => 'Another date 2'
)
);
$this->db->update_batch('mytable', $data, 'title');
// Produces:
// UPDATE `mytable` SET `name` = CASE
// WHEN `title` = 'My title' THEN 'My Name 2'
// WHEN `title` = 'Another title' THEN 'Another Name 2'
// ELSE `name` END,
// `date` = CASE
// WHEN `title` = 'My title' THEN 'My date 2'
// WHEN `title` = 'Another title' THEN 'Another date 2'
// ELSE `date` END
// WHERE `title` IN ('My title','Another title')
我究竟做错了什么?