gpt4 book ai didi

php - CakePHP 3.0 数据库修改

转载 作者:搜寻专家 更新时间:2023-10-30 23:45:19 25 4
gpt4 key购买 nike

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

在该示例中,SQL 脚本显示表 usersbookmarkstags 分别创建了 2 个名为 的字段已更新。所以我在 MySQL 数据库中运行了这个脚本。

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

我的问题是:既然我已经用所有模型、表和 Controller 烘焙了我的应用程序,我想将 updated 更改为 modified,我有吗“重新烘焙”我的 table ?

最佳答案

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

<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>

Bookmarks的index.ctp中, Users , 和 Tags .


还有:

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

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

在 3 个表的 view.ctp 中。


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

关于php - CakePHP 3.0 数据库修改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29533600/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com