OK, it depends on what you are really trying to fetch. Are you trying
to restrict the Advert results to just those that have data in the
hasMany tables, or are you trying to restrict the child table values ?

If it's the former, I would just use a condition that includes a
select for that condition specifically. For instance, in my
VolunteerCake application, I have a structure where I have a Job that
has signup Slots associated with it. I want to list jobs with
available slots (meaning there are not more Slot rows than a max field
in the jobs table), so I use a condition like:

        $whereArray =  array(
                            'AND' => array(
                                'Slot.max_signups > (select count(1)
from user_slots s2 where s2.slot_id = Slot.slot_id)',
                                'Slot.job_id = '.$id
            )
        );

Note that the "select count" is enclosed in parens, and compared to
the Slot.max_signups. This correlated sub-query causes the database to
do an implicit join, without Cake having to understand the
relationship.

If it's the latter, you can add your condition to the belongsTo or do
a separate find for the related data.

On Dec 19, 1:53 am, dev <[email protected]> wrote:
> i posted code here:http://bin.cakephp.org/saved/40741
>
> How to join Image and Option tables if i want to set these find
> conditions in Advert?
>
> I tried Containable (test2 function), but it selects all Adverts, and
> if i set conditions in first paginate array - it generates the same
> error, bicause tables don't join.
>
> How to solve this problem?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
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