CakePHP 3.0 数据库修改

CakePHP 3.0 database modification

我几天前烘焙了一个新的 CakePHP 应用程序,我制作了 Bookmarker Example

在该示例中,SQL 脚本显示表 usersbookmarkstags 各有 2 个名为 createdupdated。 所以我 运行 这个脚本在 MySQL 数据库中。

但是今天早上我发现我所有条目中的字段 updated 都是空的。
经过一番搜索,我发现该字段必须命名为 modified 而不是 updated 才能被 CakePHP 填充。

我的问题是:既然我已经用所有模型、表格和控制器烘焙了我的应用程序,我想将 updated 更改为 modified,我是否必须 "re-bake" 我的桌子 ?

我做到了。不需要重新烘焙,我只是在phpmyadmin的每个table中将modified中的字段updated重命名,然后更改为:

<th><?= $this->Paginator->sort('updated') ?></th>
进入
<th><?= $this->Paginator->sort('modified','Updated') ?></th> //sort([field],[label])

<td><?= h($bookmark->updated) ?></td> //in that case, it was Bookmarks/index.ctp
进入
<td><?= h($bookmark->modified) ?></td>

BookmarksUsersTags 的 index.ctp 中。


还有:

<p><?= h($bookmark->updated) ?></p>
进入
<p><?= h($bookmark->modified) ?></p>

<td><?= h($tags->updated) ?></td>
进入
<td><?= h($tags->modified) ?></td>

在 3 table 的 view.ctp 中。


它现在运行良好,Cake 在我更新它时填写 modified 字段。