Reputation: 105
I baked a new CakePHP app few days ago, I made the Bookmarker Example.
And in that example, the SQL script shows that the tables users
, bookmarks
and tags
have each 2 fields named created
and updated
.
So I ran this script in the MySQL database.
But this morning I realized that the field updated
was empty in all my entries.
After a little search, I found out that the field had to be named modified
instead of updated
to be filled by CakePHP.
My question is : now that I already baked my app, with all models, tables, and controllers, I would like to change updated
into modified
, do I have to "re-bake" my tables ?
Upvotes: 1
Views: 301
Reputation: 105
I made it. No need to re-bake, I just renamed the fields updated
in modified
in each table on phpmyadmin, and then changed :
<th><?= $this->Paginator->sort('updated') ?></th>
into
<th><?= $this->Paginator->sort('modified','Updated') ?></th> //sort([field],[label])
and
<td><?= h($bookmark->updated) ?></td> //in that case, it was Bookmarks/index.ctp
into
<td><?= h($bookmark->modified) ?></td>
in the index.ctp of Bookmarks
, Users
, and Tags
.
Also :
<p><?= h($bookmark->updated) ?></p>
into
<p><?= h($bookmark->modified) ?></p>
and
<td><?= h($tags->updated) ?></td>
into
<td><?= h($tags->modified) ?></td>
in the view.ctp of the 3 tables.
It now works well, Cake fills out the modified
field when I update it.
Upvotes: 1