cakephp / cakephp

CakePHP: The Rapid Development Framework for PHP - Official Repository
http://cakephp.org
MIT License
8.68k stars 3.43k forks source link

"modified" field does not get updated with current datetime #4141

Closed wenbert closed 10 years ago

wenbert commented 10 years ago

CakePHP3

Using the Edit mysite.com/products/edit/123 generated from Console/cake bake - the modified field gets updated.

But doing this manually from another controller - the modified field is not updated.

$updateQuery = $this->Products->query();
$result = $updateQuery->update()
    ->set($productData)
    ->where(['id' => $productRow->id])
    ->execute();

The other fields are updated from the $productData array. $productData['modified'] is not set.

Modified field is: `modified datetime NOT NULL`

lorenzo commented 10 years ago

Creating raw queries will not rigger any of the automatic callbacks in the Table, including the modified column saving. If you need such feature, please uses save instead.