本文介绍了绑定模型? Cakephp的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我绑定产品使用bindModel方法的子图片:
I bind ProductsPhoto to children using bindModel method:
$this->Category->bindModel(array
('hasMany' => array(
'ProductsPhoto' => array...
我可以将ProductsPhoto绑定到每个产品项目吗?
How can I bind ProductsPhoto to every product item?
还是其他解决方案建议?
Or maybe any other solution suggestion?
推荐答案
,请在您的控制器中输入以下代码
in your controller ,write below code
$this->ProductsPhoto->bindModel('hasMany' => array('Product.productphoto_id' => 'ProductPhoto.id');
在您的ProductPhoto模型中,
in your ProductPhoto model,
var $hasMany = array(
'Product' =>
array(
'className' => 'ProductPhoto',
'foreignKey' => 'productphoto_id',
'conditions' => '',
'fields' => '',
'order' => '',
'counterCache' => ''
),
);
这篇关于绑定模型? Cakephp的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!