【发布时间】:2013-02-15 05:34:47
【问题描述】:
我想在我的查询中加入join,但我无法获得任何成功,我想从product 表中找出productname,如果product_id 存在于productplan 表中。
Producttable
id name
1 a
2 b
productplantable
id product_id
1 1
2 2
这是我的查询:
$p_products = $this->ProductPlan->find('all',
array('fields'=>
array('ProductPlan.product_id',
'Product.name')
)
);
$this->set('p_products',$p_products);
【问题讨论】:
-
您是否定义了各自模型中两个表之间的关系?
-
我确定关系没有问题,产品有很多关系,产品计划属于与产品的关系
-
明显关系已经定义
-
尝试在您的查找查询上方添加
$this->ProductPlan->recursive = 2。 -
@Rikesh 不,伙计,它不起作用
标签: php mysql cakephp cakephp-1.3 cakephp-2.0