CakePHP - 表命名约定 [英] CakePHP - table naming convention
问题描述
我真的想了解CakePHP的命名约定,以下是不完全直观的。
我有两个信息:
视频 - 有关视频的特定信息
category - 具有ID,标题,说明的类别列表
我如何结构我的表?我的第一本能是:
视频
类别
video_categories
视频
类别
categories_videos
(HABTM按字母顺序排列多个型号名称)
如果您的视频只能属于一个类别,放弃 categories_videos
表,只需放置一个 category_id
字段进入视频
表。
http://book.cakephp.org/2.0/en/getting-started/cakephp-conventions.html#模型和数据库约定
I'm really trying to understand CakePHP's naming conventions and the following isn't entirely intuitive to me.
Let's say I have two pieces of information:
videos - specific information about video
category - list of categories with id, title, description
How would I structure my tables? My first instinct is:
videos
categories
video_categories
Is this right?
It should be:
videos
categories
categories_videos
(plural model names in alphabetical order for HABTM)
If your videos can only belong to one category, forgo the categories_videos
table and just put a category_id
field into the videos
table.
这篇关于CakePHP - 表命名约定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!