some tasks, but I'm trying to reduce the records I receive, not the
information within those records. I want to limit, not find, otherwise
omit records that are found in a query based on a hasMany
relationship.
for example, in the sql world, this is easy, i would write:
SELECT * FROM table where user_id NOT IN (SELECT user_id FROM table2
WHERE date = $date)
in this case, im limiting the results to the users that are not found
to have a date in table2 that matches the supplied date variable. can
this be done with containable behavior and I missed it? Or, is there
some yet to be mentioned method that I need to study?
thanks
On Sep 25, 11:54 am, teknoid <teknoid.cake...@gmail.com> wrote:
> CakePHP does not build JOINs for hasMany
>
> You can use containable behavior to pass conditions to related models.
>
> p.s. There is a trick to force cake to build JOINs, but you should
> investigate containable first.
>
> On Sep 24, 2:48 pm, Sax <sc...@brewium.com> wrote:
>
> > Cake Version: 1.2.0.7296 RC2
>
> > Thanks ahead of time for your help. I have a Model that BelongsTo
> > three other models, it also has three HasMany relationships All models
> > are "used" in my controller.
>
> > I want to do a find where I limit the results by a field in one of the
> > HasMany models and a couple fields in the BelongsTo models. The
> > problem is that the HasMany model is not joined on the SQL statement
> > and I get an error like this:
>
> > $error = "1054: Unknown column 'VendorUnavailability.date' in 'where
> > clause'"
>
> > I scoured the api, docs and google groups for an acceptable answer,
> > but none were precise and pass the simple test. What is the best way
> > to get the results Im looking for without complex Cake hacking. This
> > is a simple SQL statement that I'd rather not do manually. If more
> > information is needed, I can provide it, but I'm trying to limit the
> > amount of verbose code on here.
>
> > Thanks
--~--~---------~--~----~------------~-------~--~----~
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