Update:

3 models:
sites hasMany jobs
jobs belongsTo sites

jobs hasMany job_comments
job_comments belongsTo jobs

Site->Job->JobComment

$this->Site->find( 'all',
array('fields'=>array('Site.id'),
    'conditions' =>array(
        'Site.id' => 3),
    'contain' => array (
        'Job' => array(
             'conditions' => array (
                 'Job.site_id' => 3),
                 'JobComment' => array (
                      'fields' => array (
                          'JobComment.comment'),
                      'conditions' => array (
                          'JobComment.trouble' => 1
                                                    )
                                                  )
                                                )
                                              )
                                            )
                                        ));


On 19 авг, 16:17, Long <[email protected]> wrote:
> Greetings!
>
> I have 3 models:
>
> jobs hasMany job_comments
> job_comments belongsTo jobs
>
> Site->Job->JobComment
>
> Help me please to find works on a site which have 'trouble' comments
>
> $this->Site->find( 'all', array (  'fields'    => array('Site.id'),
>                                             'conditions' => array
> ('Site.id' => 3),
>                                             'contain' => array (
>                                             'Job' => array(
>                                                         'conditions'
> => array ('Job.site_id' => 3),
>                                                         'JobComment'
> => array (
>                                                         'fields' =>
> array ('JobComment.comment'),
>
> 'conditions' => array (
>
> 'JobComment.trouble' => 1
>                                                                          )
>                                                                )
>                                                          )
>                                                    )
>                                             )
>                                         ));
>
> ...It doesn't work good.
> I no need all Jobs on site. I need only Jobs which have
> JobComment.trouble = 1
>
> Thx.
--~--~---------~--~----~------------~-------~--~----~
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