Saving and updating the CakePHP model without changing the `created` and` modified` fields

Can any authority indicate how to save and update the database table using the save function of the model without changing the created and modified fields in cakephp 2 ..

+4
source share
2 answers

If you do not want to update the field changed while saving some data, add

 'modified' => false 

to the array $ data p>

Link: Saving Data

Hope this helps

Example:

 $this->request->data['YourModel']['modified'] = false; 
+6
source

The documentation states that setting 'modified' to false will save the modified date. However, I found that this causes the Save call to fail without any indication of what is wrong. Using unset in a modified value seems to work.

 unset( $this->request->data['YourModel']['modified'] ); 

Documentation: http://book.cakephp.org/2.0/en/models/saving-your-data.html#model-save-array-data-null-boolean-validate-true-array-fieldlist-array

0
source

Source: https://habr.com/ru/post/1391811/


All Articles