开发者

What should i call this table to follow cakePHP naming conventions?

I have a main Users table, but then i have a secondary Users_Info table, that c开发者_JS百科ontains personal info of every user, to follow the cakePHP naming conventions, how should I name this table if its supposed to be plural?

Thanks


Why not use something more intuitive like say a "profiles" table? Unless you are already using that for something else in your app. In your case remember that only the last word in your table name needs to be plural. Note that "users_infos" table sounds more like name for a HABTM table, only when following cake conventions you would order the table names alphabetically as "infos_users" for a HABTM table (http://book.cakephp.org/view/1044/hasAndBelongsToMany-HABTM). So to answer your question you should be able to simply add an s to your table name as stated above and it should work.

cheers


What serialk says is true: using a "profiles" table is the best schema design. Nevertheless, if you are unable to use "profiles" table, and since each user will generally have a single profile (Unless your application is providing option of multiple profile identities for each user), I guess you won't be needing a HABTM table "infos_users".

Coming to Cake's conventions, the conventions are designed to be as close to real world as possible. The table where books are stored is called Books and where categories are stored is called Categories. But the table where news is stored is still called as News and the table where information is stored is still called as Information, not Informations.

So, you can safely proceed using users_info table. It is not a violation of Cake's conventions. Cake will generate a UsersInfo model and a UsersInfo controller which you can use without any issue even though both or singular.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜