【发布时间】:2015-06-28 20:55:25
【问题描述】:
您好,我有两个模型类别和产品。 Category 模型具有如下表结构:"id, name",Product 具有:"id, name, category_id"
当我退回所有产品时,我希望将 category_id 字段替换为 "categories" 表中对应的 "name" 值。
示例:
类别:
id name
1 cloth
2 food
产品:
id name category_id
1 carrot 2
2 pants 1
3 shirt 1
结果
id name category_id
1 carrot food
2 pants cloth
3 shirt cloth
【问题讨论】: