The uses array is only there to test the Variations call, I would
remove it in finished thing.

The plurals are the names of the arrays I thought, and as such didn't
matter what I called them..?

Also, I dont like the convention of naming id fields 'just' id, I'm
cool with the config options tho, I can handle that...

Cheers for the points tho, I'll definately check out that 'belongs'
issue!

Cheers,

d.

On Nov 24, 10:20 am, "DJ Spark" <[EMAIL PROTECTED]> wrote:
>  also, you don't need, usually, to use more than one model per
> controller ( uses('Model1', 'Model2') ), if they are associated
> somehow:
> this
>  $this->Variations->findAll()
>
> could be
>  $this->Product->Variation->findAll()
>
>  I didn't run any tests, but I can see some points:
>
> class VariationOption extends AppModel
> {
>    var $name = 'VariationOption';
>    var $primaryKey = 'vo_id';
>
>  // Add this to ensure the association
>    var $belongsTo = 'Variation';
>
> }
>
> Also, in the Product association, I can see a plural there
>
> var $hasAndBelongsToMany = array('Variations' =>
>                                   array('className'    => 'Variation',
>
> try changing it to singular form:
>
> var $hasAndBelongsToMany = array('Variation' =>
>                                   array('className'    => 'Variation',
>
> And setting the HABTM association also on the VariationOption model
>
> If you area starting with cake, i'd also suggest to *really* use all
> cake conventions, like db table 'id' :)
> Doing so, you would need all those HABTM options, like table_name,
> primary key, et cetera.
>
> Spark
>
> On Nov 23, 2007 9:01 PM, designvoid <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > 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 -
>
> --
> [livesets]http://djspark.com.br/
> [web]http://sydi.net
> [filmes]http://melhoresfilmes.com.br
--~--~---------~--~----~------------~-------~--~----~
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