Hi everyone,
Long time I have no post something.
Today I will write something about "
Table and Model Name in Cakephp".
As you know, in Cakephp we should write the name of table in plural.
I mean for example if you want make table with name "
user" you should make it like "
users" and "
post" should be "
posts".
So how to handle table names that are written in singular with "...y"?
hehe ...
just so simple, I make an example with table name "
entry" and it should be "
entries". :D
But for Model name in cakephp you should write the name in singular.
you already have a table "
entries", than in your
app\models , you should make a new file for model. The name of the file is "entry.php" (in singular 'user.php, post.php').
And below is basic code for Model Name :
class Entry extends AppModel {
var $name = 'Entry';
}
How about if we use underscore in our table names??
for example you have table name "
categories_lists", how will we make the Model name?
I show you the simple way,
in your
app\models, create a new file with name "
categories_list.php".
write this code inside of the file :
class CategoriesList extends AppModel {
var $name = 'CategoriesList';
}
Ok, that's all
if you have any question, just write your comment below :D
Thanks for your visit.
warm regard from bali :)