On Tue, Apr 19, 2011 at 9:20 AM, jackgoh <[email protected]> wrote:
> Hi,
>
>
> I try to use the following method to develop the CRUD when involve two
> tables or more:
>
>                $this->Product-
>>unbindModel(array('hasOne'=>array('ProductDetail')));
>                $this->Product->bindModel(array('hasOne'=>array(
>                                'ProductDetail'=>array(
>                                        'foreignKey'=>false,
>                                        
> 'conditions'=>array('ProductDetail.product_id=Product.id')
>                                )
>                )

Is there a compelling reason why you're unbinding, then binding these
models with the same association?

> But i found out the result will add an extra level, the [0]:
> Array
> (
>    [0] => Array
>        (
>            [Product] => Array
>                (
>                    [id] => 1
>                    [stock_code] =>
>                    [short_name] => xxx
>
>                )
>
>            [ProductDetail] => Array
>                (
>                    [id] => 1
>                    [product_id] => 1
>                    [description] => YYYYYY
>
>                )
>
>        )
>
> )

What does the find() look like?

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to