update batch codeigniter

Solutions on MaxInterview for update batch codeigniter by the best coders in the world

showing results for - "update batch codeigniter"
Dario
01 Mar 2018
1$data = array(
2   array(
3      'title' => 'My title' ,
4      'name' => 'My Name 2' ,
5      'date' => 'My date 2'
6   ),
7   array(
8      'title' => 'Another title' ,
9      'name' => 'Another Name 2' ,
10      'date' => 'Another date 2'
11   )
12);
13
14$this->db->update_batch('mytable', $data, 'title');
15
16// Produces:
17// UPDATE `mytable` SET `name` = CASE
18// WHEN `title` = 'My title' THEN 'My Name 2'
19// WHEN `title` = 'Another title' THEN 'Another Name 2'
20// ELSE `name` END,
21// `date` = CASE
22// WHEN `title` = 'My title' THEN 'My date 2'
23// WHEN `title` = 'Another title' THEN 'Another date 2'
24// ELSE `date` END
25// WHERE `title` IN ('My title','Another title')
26