Hello Readers,
Below is used to update the single field in CakePHP.
In CakePHP, if we can update the one field into the database to do this w have two methods to update the field.
1> First using savefield() method:
Example:
$this->ModelName->id=$id;
$this->ModelName->saveField("fieldName","value");
In the above example, we have used the model id (which id record is updated) and used savefield("fieldName","value") method which having 2 parameters fieldname and it's value.
2> Second one is using the updateAll() method:
$this->Model->updateAll(array("fieldName"=>"value"),array("fieldName"=>"condition"));
Example:
In the above example code, we have used updateAll(array("fieldName"=>"value")) method having fieldname and its value.
0 Comment(s)