forked from codeigniter4/CodeIgniter4
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path092.php
More file actions
28 lines (26 loc) · 658 Bytes
/
Copy path092.php
File metadata and controls
28 lines (26 loc) · 658 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
$data = [
[
'title' => 'My title',
'name' => 'My Name 2',
'date' => 'My date 2',
],
[
'title' => 'Another title',
'name' => 'Another Name 2',
'date' => 'Another date 2',
],
];
$builder->updateBatch($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')
*/