开发者

Creating Model without associations

开发者 https://www.devze.com 2023-03-23 21:46 出处:网络
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. 开发者_JAVA百科Then

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. 开发者_JAVA百科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.


Why store them in the database? Why not just write the static pages in the view/pages directory?

If you want to create a model for pages, I would name it something different like "contents". Then you can load the model and pull the data from anywhere:

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

So the answer is yes, you can create a table that only holds data without any associations.

0

精彩评论

暂无评论...
验证码 换一张
取 消