Skip to content

Commit 02ce252

Browse files
committed
:octocat:
1 parent 9c9a69c commit 02ce252

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,35 @@ method | description
404404
`openBracket($join = null)` | see `Select::openBracket()`
405405
`closeBracket()` | see `Select::closeBracket()`
406406

407+
Single row update
408+
```php
409+
$db->update
410+
->table('table_to_update')
411+
->set(['col_to_update' => 'val1'])
412+
->where('row_id', 1)
413+
->query();
414+
```
415+
416+
Update multiple rows
417+
```php
418+
$values = [
419+
// [col_to_update, row_id]
420+
['val1', 1],
421+
['val2', 2],
422+
['val3', 3],
423+
];
424+
425+
$db->update
426+
->table('table_to_update')
427+
->set(['col_to_update' => '?'], false) // disable value binding here
428+
->where('row_id', '?', '=', false) // also disable binding here
429+
->multi($values);
430+
```
431+
432+
The generated SQL for both examples would look like the following, the difference is that one performs a single query, while the other loops through the given value array in the open prepared statement.
433+
```mysql
434+
UPDATE `table_to_update` SET `col_to_update` = ? WHERE `row_id` = ?
435+
```
407436

408437
### `Delete`
409438

0 commit comments

Comments
 (0)