Baking tables in cake php - cakephp

Im baking tables in cakephp. One table named abc which I baked successfully and I need to remove this table from database and also from the cakephp folder. I deleted all models, controllers, views and test fixture for that table. But due to some reasons now when Im baking my next tables it gives me an error "Missing database table 'abc' for model 'abc'. I dont know from where the error is coming. I deleted all files related to abc.

Try deleting all of the models in \app\models and then rebake them.

Try deleting content of the app/tmp/cache/models directory.

Related

cakephp - naming tables and using cake bake

I'm having some weird behaviour from the cake console and I can't figure out what could possibly be wrong!
I've used the cake bake console before and not had any problems so hopefully it's not something glaringly stupid.
I have the tables: users, images and folders.
Folders and images both have user_id's
When I run the cake bake all on the folders table it bakes the controller and model but there's errors baking the views. I figured perhaps you can't call a table folders because of conventions or whatever so I renamed it 'archives'.
Now when I run the console and cd to myApp/app and cake bake all I get the model:
1 archife
2..
archife??
My table is most definitely called archives. I've changed the name a bunch of times to other names to check and it only seems to be on the particular word archives which it turns into archife. I've checked other words with 'v' in it but they're fine.
So.. my questions are twofold. Can we not use the table name folders because there's some problem with it? It's the only name I've come across apart from pages which you can't use as a table name because it clashes.
And, why does cake bake the table archives to the model archife?
Model names should be unique...
As a general rule, don't use names for your tables that would result in a model class name that equals an existing class name, Folder for example is a utility class shipping with CakePHP, and this will cause problems with autoloading as you've experienced.
This is a problem that should/will be fixed with CakePHP 3, where namespaces are being used.
...and singular
archives being turned into archife sounds like it could be an Inflector bug/conflict, try
debug(Inflector::singularize('archives'));
It's working fine for me using CakePHP 2.5.1, ie it returns archive as expected, so I'd suggest to upgrade your CakePHP version, and report it as a bug in case it's happening with a recent version.

cakephp database table not found error after copied to local

i am using cakephp 1.3 ...it was working like charm in server ,i copied it to local and executed it....after that it shows a wierd error .It says "Missing Database Table
Error: Database table inboxes for model Inbox was not found.
Notice: If you want to customize this error message, create app/views/errors/missing_table.ctp
"
things i did after copying to local:
i used same DB with different name (yes..i changed in database.php too)
But there exist table "inbox"
I tried these ways:
1.removed inbox model and controller--nothing hapened
2.removed cache file from app/tmp/cache/models ---nothing happened
3.disabled caching from core.php
when i used another table with same name as in server its working
But nothing seems to be working after i used another database name as i am using that db name for another app ....can anyone help me on this...whats really happening with this.,its urgent..thanks in advance...
As Joseph mentioned in the comment, it may be a spelling mistake. But there could be one more reason:
On the web servers sometimes (mostly on shared hosting) you have the database name prefix. So it is possible that the real name of the database on your server is different from the database on your localhost. You can configure this in your app folder config/database.php
Best regards,
Tony.
After days of headache i sorted it out.
Even if i was using same DB with different name,it was using different encoding .I created new db with uttf_genereal_ci encoding and imported old one into it.Now its working like charm.Thanks guys for helping me on this

CakePHP 1.3 and table not found after renaming a table and regenerating the model

I renamed a table recently, and tried to regenerate the model. For some reason it keeps saying "Error: Missing database table" for the old table name. I can't seem to get rid of it, I cleared the cache, etc.
Any ideas? Thanks!
most likely you forgot to remove a relationship to that old model.

How to create a Controller in CakePHP without setting up database tables?

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
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.
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..
For the static pages such as Home, About and Help you could use the PagesController
Cheers!

Cakephp - Baking custom models

I need to bake a large project but a requirement is each model has its schema listed at the top as a multi-line comment.
Any ideas ?
Thanks, Alex
Start in your [PATH]/cake/console/templates/classes/model.ctp file.
Manually connect to the database using an old-fashioned php connect string.
Pull the table structure in a "describe" query.
Loop through, print out the table structure in comments.
cake bake...

Resources