Cake-PHP

UPDATE SINGLE FIELD IN DB USING CAKEPHP

This code shows how to update one single field in the database using CakePHP 2.x. It is as simple as this:

$this->User->id = $id;
$this->User->saveField('is_active', 1);

In case we are in an other controller or model as User, we can simply load the User model:

$this->loadModel('User');
$this->User->id = $id;
$this->User->saveField('is_active', 1);

Leave a Reply