It's kind of silly that it doesn't provide the associations for
hasMany by default when you would think so. What would be the most
logical reason for this?
Also, if I unbind an association at the Model level, I assume that all
further calls for the Model within Controllers would also be affected?
unlike unbinding in a Controller and having the binds restored on the
next call by default. The reason for this (I know I could use the
Bindable behavior) is if I created a method in a Model, it could
unbind any associations and return the result. However I am thinking
that the binds would have to be manually defined again, which is
obviously not very efficient...
On Jul 31, 3:59 am, Teh Treag <tehtr...@gmail.com> wrote:
> Dean,
>
> CakePHP will not produce a join for hasMany and HABTM finds. As a
> result, the fields of the associated table are not avaiable for the
> query. There are a variety of techniques to get what you want.
>
> There's the linkable behavior, ad-hoc join, and a method using
> bindModel to bind the relationship as a hasOne to get CakePHP to do
> the joins. These are discussed in the manual, on the bakery, and in
> blogs.
>
> On Jul 29, 9:45 pm, dean <hamish.dea...@gmail.com> wrote:
>
> > Hi all,
>
> > I'm having a slight problem with querying data on an association I've
> > created.
>
> > The two models are Product and ProductVariation. The ProductVariation
> > model belongs to the Product model and the Product model hasMany
> > ProductVariations.
>
> > This is all well and good until I attempt to run the following query:
>
> > $this->Product->find('all', array('conditions' =>
> > array('ProductVariation.id' => 5)));
>
> > I get a notice saying - SQL Error: 1054: Unknown column
> > 'ProductVariation.id' in 'where clause'
>
> > I don't understand, the models are associated and when I pull out a
> > single product by its ID, the ProductVariation's are retrieved as
> > well, but I cannot seem to get a condition bound to that column!
>
> > Any insight would be greatly appreciated.
>
> > Thanks in advance
>
>
Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
No comments:
Post a Comment