Hi: I'm taking a liberty with your Models, because I don't know how
Post can belongTo Post, so I'm making Post belongTo Topic, and I'm
thinking of something along the lines of this:

'fields' =>     array(
                        'TopicCategory.title',
                        'COUNT(DISTINCT Topic.id) As topic_total',
                        'COUNT(DISTINCT Post.id) As post_total'
                        ),
'joins' =>      array(  array(  'type' => 'INNER',
                                'table' => 'topics',
                                'alias' => 'Topic',
                                'conditions' => array(
                                                        'Topic.id = 
TopicCategory.topic_id'
                                                         )
                                ),
                        array(  'type' => 'LEFT',
                                'table' => 'posts',
                                'alias' => 'Post',
                                'conditions' => array(
                                                        'Post.topic_id = 
Topic.id'
                                                         )
                                )
                        )
'group' => array('TopicCategory.id')

- Rob

On May 11, 10:39 am, "Carlos Eduardo Sotelo Pinto"
<[email protected]> wrote:
> Hi people
> I need a help on a find query like this
>
> Models
> =======
> TopicCategory => ( habtm=>Topic )
> Topic => (habtm => TopicCategory, hasMany=>Post)
> Post => (belongsToPost)
>
> I need something like
>
> --------------------
> TopicCategory.title
> Topic total
> Post total
> --------------------
>
> HOw could be the find query for this result, that as you can see it is a  
> forum
>
> thanks
>
> --
> Carlos Eduardo Sotelo Pinto
>      PHP Senior Web Developer
>      Cell (preferred): (Mov)+51, 959980794 :: (Claro)+51, 952707662
>      http://www.csotelo.org
>      Skype: csotelop
>      Yahoo: csotelop
>      MSN: [email protected]
>      GTalk: [email protected]
> GPG FP:697E FAB8 8E83 1D60 BBFB 2264 9E3D 5761 F855 4F6B
> GNULinux RU #379182 || GNULinux RM #277661

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php
  • Complex find Carlos Eduardo Sotelo Pinto
    • Re: Complex find Rob Maurer

Reply via email to