I have full debug on and all the queries seem to be correct.

If I change:

$this->set('products', $this->Product->findAll());

to

$this->set('products', $this->Variations->findAll());

it it comes back with the variations and associated options fine! So
it seems the join between 'groups' the 2 is screwy somewhere... i can
return products and vars and vars and options but not all in one go!
LOL!

d.



On Nov 23, 9:58 pm, bingo <[EMAIL PROTECTED]> wrote:
> hi designvoid
>
> I am 100% confident it has something to do with how setup HABTM
> (belongsTo, etc) relationships. CakePHP is pretty good in dealing with
> recursive queries. One way to figure out what's happing is to use
> debug mode  = 2 . That will print out all the SQL queries and will
> allow to see what's going on.
>
> Regards,
>
> On Nov 23, 3:15 pm, designvoid <[EMAIL PROTECTED]> wrote:
>
> > Hi Bingo,
>
> > Cheers for the heads up on that - I'll definately give it a shot!
>
> > I'm still wondering tho, is it my code that is the problem or a
> > limitation of Cake? I'd like to fully understand why this issue is
> > occuring before moving on to other scripts etc...
>
> > d.
>
> > On Nov 23, 8:00 pm, bingo <[EMAIL PROTECTED]> wrote:
>
> > > hi designvoid,
>
> > > I would suggest you that you get that script. In my experience of
> > > using CakePHP, I found it very useful. But I started using that script
> > > before CakePHP 1.2 came into existence and continuing to still use it
> > > in 1.2. You might also want to see if 1.2 has any such functionality.
>
> > > Regards
>
> > > On Nov 23, 1:49 pm, designvoid <[EMAIL PROTECTED]> wrote:
>
> > > > I'm not using that script, I'm relatively new to Cake, making good
> > > > progress but this has stumped me...
>
> > > > Is that script needed to do what I want? Or is there a way in vanilla
> > > > Cake?
>
> > > > t.
>
> > > > On Nov 23, 6:19 pm, bingo <[EMAIL PROTECTED]> wrote:
>
> > > > > I guess you need to set  (assuming you are using unbindModel 
> > > > > scripthttp://bakery.cakephp.org/articles/view/an-improvement-to-unbindmodel...)
>
> > > > > $this->Product->Variations->expects('Options);
> > > > > $this->Product->expects('Variations);
> > > > > $this->set('products', $this->Product->findAll());
>
> > > > > bingo
>
> > > > > On Nov 23, 12:59 pm, designvoid <[EMAIL PROTECTED]> wrote:
>
> > > > > > Hi all,
>
> > > > > > I'm having a wierd issue when trying to use 3 models together via 1
> > > > > > findAll()... I'll paste the code then, explain what's happening,
> > > > > > fingers crossed one I you fine folk will be able to give a me a
> > > > > > pointer as to what I'm missing...
>
> > > > > > Basic overview:
>
> > > > > > Products has multiple Variations and Variations have multiple 
> > > > > > Options
>
> > > > > > Code:
>
> > > > > > class Product extends AppModel {
> > > > > >    var $name = 'Product';
> > > > > >    var $primaryKey = 'p_id';
>
> > > > > >     var $hasAndBelongsToMany = array('Variations' =>
> > > > > >                                    array('className'    =>
> > > > > > 'Variation',
> > > > > >                                          'joinTable'    =>
> > > > > > 'products_variations',
> > > > > >                                          'foreignKey'   => 'p_id',
> > > > > >                                          'associationForeignKey'=>
> > > > > > 'v_id',
> > > > > >                                          'conditions'   => '',
> > > > > >                                          'order'        => '',
> > > > > >                                          'limit'        => '',
> > > > > >                                          'unique'       => true,
> > > > > >                                          'finderQuery'  => '',
> > > > > >                                          'deleteQuery'  => '',
> > > > > >                                    )
> > > > > >                                 );
>
> > > > > > }
>
> > > > > > --------------------------------------
>
> > > > > > class Variation extends AppModel
> > > > > > {
> > > > > >     var $name = 'Variation';
> > > > > >     var $primaryKey = 'v_id';
>
> > > > > >     var $hasMany = array('Options' =>
> > > > > >                      array('className'     => 'VariationOption',
> > > > > >                            'conditions'    => '',
> > > > > >                            'order'         => '',
> > > > > >                            'limit'         => '',
> > > > > >                            'foreignKey'    => 'vo_v_id',
> > > > > >                            'dependent'     => '',
> > > > > >                            'exclusive'     => '',
> > > > > >                            'finderQuery'   => '',
> > > > > >                            'fields'        => '',
> > > > > >                            'offset'        => '',
> > > > > >                            'counterQuery'  => ''
> > > > > >                      )
> > > > > >               );
>
> > > > > > }
>
> > > > > > --------------------------------------
>
> > > > > > class VariationOption extends AppModel
> > > > > > {
> > > > > >     var $name = 'VariationOption';
> > > > > >     var $primaryKey = 'vo_id';
>
> > > > > > }
>
> > > > > > -----------------------------------------------------
>
> > > > > > Now when I run:
>
> > > > > >         $this->Product->recursive = 3;
> > > > > >         $this->set('products', $this->Product->findAll());
>
> > > > > > I only get the following back:
>
> > > > > > Array
> > > > > > (
> > > > > >     [0] => Array
> > > > > >         (
> > > > > >             [Product] => Array
> > > > > >                 (
> > > > > >                     [p_id] => 1
> > > > > >                     [p_name] => A Jumper
> > > > > >                     [p_description] => Its a lovely wooly jumper for
> > > > > > the winter
> > > > > >                     [p_image] => jumper.jpg
> > > > > >                     [p_price] => 10.00
> > > > > >                 )
>
> > > > > >             [Variations] => Array
> > > > > >                 (
> > > > > >                     [0] => Array
> > > > > >                         (
> > > > > >                             [v_id] => 1
> > > > > >                             [v_name] => Sizes
> > > > > >                         )
>
> > > > > >                 )
>
> > > > > >         )
>
> > > > > > --------------------
>
> > > > > > Now to my reckoning there should be an Options array under
> > > > > > Variations...
>
> > > > > > Hope its something simple I've missed and someone can put me 
> > > > > > straight!
> > > > > > Thanks in advance,
> > > > > > d.- Hide quoted text -
>
> > > > - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to