Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有 3 张桌子:
如何从numbers_food关系表中获取每个food_id的price_per_ad和price_per_ch数据?
只需在模型中定义关系。
在 NumberFoodModel 中:
'food' => array(self::BELONGS_TO, 'Food', 'food_id'),
在 FoodModel 中:
'number_food' => array(self::HAS_MANY, 'NumberFood', 'food_id'),
现在在您的代码中使用
Food::model()->with('number_food')->findByPk($id)