开发者

Can not Bake table model, controller and view

I developed small CakePHP application, and now I want to add one more table (in fact, model/controller/view) into system, named notes. I had already created a table of course.

But when I run command cake bake model, I do not get table Notes on the list. I can add it manually, but after that I get some errors whe开发者_开发知识库n running cake bake controller and cake bake view.

Can you give me some clue why I have those problems, and how to add that new model?


I would also check your app/config/database.php to ensure that you are using the correct database configuration. You may well have added the table to a different database perhaps and the bake is picking up the other database. Also, and this may be obvious, but check you are in the right project, it's easy to be in a different folder and not realise, especially if you have lots of projects.

I'm not aware of a limit on the bake listing. I would check your database to make sure the table exists and has some columns. You can always open up the console bake script and check for a limit and increase it if needs be.


I found solution!

I had to delete all from cache directory, /app/tmp/cache/models

Now it works! :-)


When you say added it manually, do you mean added the note.php model? If not, you may want to try that. Verify that the model name is correct for the following:

file name: note.php
class name: class Note extends AppModel
table name: notes

Also, be sure the notes table has the id column and it is set to primary key.

If this does not push you in the right direction, please post your notes table schema here. Also, have you had success in baking other things in your app? Have you upgraded anything?


Please change the following farameters to bake:

For Controller:

/cake/console/libs/tasks/controller.php

function listAll($useDbConfig = 'default') {

change to :

function listAll($useDbConfig = 'YOUR DB CONFIG NAME') {

NOW DO CAKE BAKE for CONTROLLER! ENJOY!

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜