如何在CakePHP中创建控制器而不设置数据库表? [英] How to create a Controller in CakePHP without setting up database tables?

查看:167
本文介绍了如何在CakePHP中创建控制器而不设置数据库表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很新的cakePHP,但我有一点知识Ruby on Rails。我尝试在控制台中使用 cake bake 命令创建一个控制器,但它说:

I am very new to cakePHP but I am a bit knowledgeable with Ruby on Rails. I tried creating a controller using the cake bake command in the console but it said:


您的数据库没有任何表

Your database does not have any tables

就我记得在rails中,它允许我创建没有表的控制器即使没有设置数据库。我想要做的是,我想为诸如首页关于帮助之类的页面创建控制器和视图。我不认为这些页面仍然需要一个模型或数据库表。

As far as I can remember in rails, it allowed me to create controllers without tables or even without setting up database. What I am trying to do is that I want to create a controller and a view for pages such as Home, About, and Help. I don't think those pages still need a model or a database table. Pls help.

推荐答案

确保您可以创建控制器和视图,甚至没有表格的模型。

sure you can create controllers and views... even models without tables.

但是你不能烘焙它们= D bake只是读取数据库,并帮助你从那里创建你的类。所以,如果你没有任何表,你没有任何东西烘烤..

But you can't bake them =D bake is just to read the database and help you create your classes from there. So if you dont have any table, you dont have anything to bake..

对于静态页面如Home,About和Help,你可以使用 PagesController

For the static pages such as Home, About and Help you could use the PagesController

干杯!

这篇关于如何在CakePHP中创建控制器而不设置数据库表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆