开发者

Bindmodel to binded model? Cakephp

开发者 https://www.devze.com 2023-03-17 03:55 出处:网络
I bind Products开发者_StackOverflowPhoto to children using bindModel method: $this->Category->bindModel(array

Bindmodel to binded model? Cakephp

I bind Products开发者_StackOverflowPhoto to children using bindModel method:

$this->Category->bindModel(array
            ('hasMany' => array(
                'ProductsPhoto' => array... 

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');

in your ProductPhoto model,

var $hasMany = array(
    'Product' =>
                array(
                    'className' => 'ProductPhoto',
                    'foreignKey' => 'productphoto_id',
                    'conditions' => '',
                    'fields' => '',
                    'order' => '',
                    'counterCache' => ''
            ),  

);


On the fly: $this->ProductsPhoto->bindModel('hasMany' => 'Product');

Via ProductsPhoto class property: $hasMany = 'Product';

0

精彩评论

暂无评论...
验证码 换一张
取 消