Daniel Faria Daniel Faria - 1 year ago 71
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])


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download