Update a row(entity) in a table only if a change detected(automatically) -


sorry bad english :(

i'm using cakephp 3 framework , want update row(entity) in table if a change detected(automatically).

eg.:

$id = 1; // debug($this->request->data) $this->request->data = ['id' => 1, 'name' => "my name", 'content' => "my content"]; // inside articlescontroller $article = $this->articles->get($id); // debug($article) object(cake\orm\entity) {     'id' => (int) 1,     'name' => "my name",     'content' => "my content",     '[new]' => false,     '[accessible]' => [         '*' => true     ],     '[dirty]' => [],     '[original]' => [],     '[virtual]' => [],     '[errors]' => [],     '[repository]' => 'articles' } 

there no difference between the request data , the original data have reject update query , return warning user "no changes detected !"

what have ?

thanks

each entity has field 'dirty' shows if entity has been updated.

you use :

if($article->dirty()) {     // send flash message } 

check book here : http://book.cakephp.org/3.0/en/orm/entities.html#checking-if-an-entity-has-been-modified


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -