0

I'm planning to implement some static pages on my current CakePHP site.

These static pages would be stored in a table called pages where it will have 2 field; title and content. Then for example, in the users_controller, I can do a find for the 'Welcome' static entry and set it into the view.

Can I create a model for pages without any association because this table in logic does not have any association with the other tables.

Is there any other best way I can implement this with simplicity in mind? Thanks.

4

1 回答 1

1

为什么将它们存储在数据库中?为什么不直接在 view/pages 目录中写静态页面呢?

如果您想为页面创建模型,我会将其命名为不同的名称,例如“内容”。然后您可以加载模型并从任何地方提取数据:

$this->loadModel('Content');
$this->Content->find(...);

所以答案是肯定的,你可以创建一个只保存数据而没有任何关联的表。

于 2011-08-02T03:45:43.913 回答