Skip to content

Instantly share code, notes, and snippets.

@robertscherer
Created September 5, 2014 08:36
Show Gist options
  • Select an option

  • Save robertscherer/1386d3f2a2b55a087789 to your computer and use it in GitHub Desktop.

Select an option

Save robertscherer/1386d3f2a2b55a087789 to your computer and use it in GitHub Desktop.
CakePHP 3 Query Update
<?php
$updateQuery = $this->query();
$updateQuery->update();
$updateQuery->set([
'workerkey' => $key,
'fetched' => date('Y-m-d H:i:s')
]);
$updateQuery->where($where);
$updateQuery->limit(1);
$updateQuery->order([
$ageField => 'ASC',
'id' => 'ASC'
]);
?>
Results in
UPDATE queued_tasks SET workerkey = '1f27027e65456a5cc1e1bb6e737c09feb851c1f7' , fetched = '2014-09-05 08:30:10' WHERE (id = 1 AND ((workerkey) IS NULL OR fetched <= '2014-09-05 08:28:30'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment