Skip to content

Latest commit

 

History

History
41 lines (39 loc) · 951 Bytes

Update.md

File metadata and controls

41 lines (39 loc) · 951 Bytes

UPDATE

Update a row

$query->update('users', [
            'username' => 'John Doe',
            'status' => 'new status'
        ])
        ->where([['id', '=', 7]])
        ->limit()
        ->go();

or since v0.3.4

$query->update('users', [
            'username' => 'John Doe',
            'status' => 'new status'
        ])
        ->where([['id', 7]])
        ->limit()
        ->go();

Result query

UPDATE `users` SET `username` = 'John Doe', `status` = 'new status'
WHERE `id` = 7 LIMIT 1;

Update rows

$query->update('posts', ['status' => 'published'])
        ->where([['YEAR(`updated_at`)', '>', 2020]])
        ->go();

Result query

UPDATE `posts` SET `status` = 'published'
WHERE (YEAR(`updated_at`) > 2020);

To the DELETE section

Back to doc index or readme