Daniel Faria Daniel Faria - 11 months ago 59
PHP Question

Update only one field on Cakephp 3

In some part of my app I need to update only the field

of some
with a lot of fields. What is the best approach to update only this field and avoid the validations and requiriments of all other fields?

Answer Source

This will work:

$users = TableRegistry::get('Users');
$query = $users->query();
    ->set(['is_active' => true])
    ->where(['id' => $id])