【发布时间】:2012-08-19 13:09:56
【问题描述】:
以下场景:
Recipe hasMany RecipeItem
RecipeItem belongsTo Recipe, Ingredient
(Ingredient 可以与 hasMany RecipeItem 关联,但我不需要这种关系。)
所以基本上,一个没有连接表的单面HABTM,因为我的连接元素(RecipeItem)需要有一个额外的属性:count。
这篇文章:http://book.cakephp.org/1.3/view/1650/hasMany-through-The-Join-Model 描述了如何一次创建/保存全部或完全分离。我想要的是创建分离的一侧(成分)和关联的另一侧(食谱)。创建新配方时,您可以选择多种成分。
你会怎么做? 谢谢。
【问题讨论】:
-
试着用cakeapp.com搞清楚
标签: php cakephp join has-and-belongs-to-many