Quantcast
Channel: Cakephp: Update records without refering the primary key - Stack Overflow
Viewing all articles
Browse latest Browse all 3

Answer by Farray for Cakephp: Update records without refering the primary key

$
0
0

saveField is only intended to work on the currently loaded record. To update multiple records of the same model, use updateAll.

Usage:

Model::updateAll(array $fields, array $conditions)

Updates many records in a single call. Records to be updated are identified by the $conditions array, and fields to be updated, along with their values, are identified by the $fields array.

source

In your case, it would look like this:

$this->Contact->updateAll(    array( 'Contact.is_read' => 'y' ),   //fields to update    array( 'Contact.id_thread' => $id )  //condition);

Viewing all articles
Browse latest Browse all 3

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>