cakephp: Query::update() does not support LIMIT
This is a (multiple allowed):
- bug
- enhancement
- feature-discussion (RFC)
- CakePHP Version: 3.2.12
- Platform and Target: Apache2, MySQL, PHP 7
What you did
Trying to create a custom update query that has a LIMIT 1
$query = $documents->query()->update()->set(['title'=>'foo'])->limit(1);
Log::info((string)$query);
Output:
UPDATE `documents` SET `title` = :c0
Expected Behavior
MySQL supports LIMIT on UPDATE queries, but the ORM is not adding the LIMIT clause.
Actual Behavior
All records are updated. 😢
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 17 (16 by maintainers)
I don’t see why not. We support a few other non-standard sql dialect features in the same way.
I’m going to close this issue as there would be no way of implementing this reliably in all databases. As a workaround for mysql, You can do