关于cakePHP和命名约定似乎有很多问题。虽然文档非常精彩,但我觉得它可以更加精确和完整。
我具体有两个问题: 1)当一个单词没有复数形式时,最佳做法是什么?就我而言,staff
这个词让我感到头痛。
下面你可以找到我目前的理解,因为它与第二个模型#34; kid"有关。
2)什么是不使用HABTAM时的命名约定,而是在连接模型的每一侧使用$ hasMany和$ belongsTo。
Joining With "Kid"
Word in | American English | Database | Model | Controller | Joining Table | Joining Model | JoiningController
question | Plural form | table | Name | Name | Name | Name
=========+==================+==========+========+==================+==================+===============+===================
Person | People | people | Person | PeopleController | kids_people | KidPerson | KidsPeopleController
Duck | Ducks | ducks | Ducks | DucksController | ducks_kids | DuckKid | DucksKidsController
Staff | Staff | staff | Staff | StaffController | staff_kids | StaffKid | StaffKidsController <-- ReQ2: Is this correct? ReQ1: My interpretation of documentation.
. ^ ^ ^ ^
Staff | Staffs | staffs | Staff | StaffsController | staffs_kids | StaffKid | StaffKidsController <-- ReQ1: Seems to want.
Duck | Ducks | ducks | Ducks | DucksController | duck_kids | DuckKid | DuckKidsController <-- ReQ2: Seems to want.
答案 0 :(得分:2)
Inflector::pluraize('staff')
方法测试相应的复数。这是cake用于命名约定的类。我的尝试给了我员工。