Move the OfficeDesk condition to the main condition.

Also, use array-based condition:
array(
   'Model.field' => 'value'
)

On Thu, Nov 20, 2008 at 3:08 PM, morris <[EMAIL PROTECTED]> wrote:

>
> I'm seeing some odd behavior when using Containable with conditions.
>
> I have a model... lets call it 'DustParticle'.. it belongs to two
> other models
> DustParticle belongs to Broom
> and
> DustParticle belongs to OfficeDesk
>
> anyhow.. try not to read too much into the dust concept.
>
> When I run something like this:
>
> $this->DustParticle->find(
>                        'count',
>                        array(
>                                'conditions' => array(
>                                        "DustParticle.user_id = $an_id"
>                                        ),
>                                'contain' => array(
>                                        'OfficeDesk' => array(
>                                                'conditions' => array(
>                                                        "OfficeDesk.active =
> 'yes'"
>                                                        )
>                                                )
>                                        )
>                                )
>                        );
>
> the resulting query is:
>
> SELECT COUNT(*) AS `count` FROM `dust_particles` AS `DustParticle`
> LEFT JOIN `office_desks` AS `OfficeDesk` ON
> (`DustParticle`.`office_desk_id` = `OfficeDesk`.`id` AND
> `OfficeDesk`.`active` = 'yes') WHERE `DustParticle`.`user_id` = '3'
>
>
> the problem being that it put that extra condition (OfficeDesk.active
> = yes) into the JOIN..ON statement.
>
> my question is, i suppose, is this a known problem? or should I submit
> a ticket? or perhaps i'm just using containable incorrectly?
>
> it only seems to occur (so far) when I have a Model that belongs to 2
> other models. I have a couple other queries that use containable
> conditions.. but they are hasMany relationships and this problem
> doesn't show up.
> >
>


-- 
Renan Gonçalves aka renan.saddam
Software Engineer - CakePHP Core Developer
Cell Phone: +55 11 8633 6018
MSN: [EMAIL PROTECTED]
São Paulo - SP/Brazil

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to