Here's what I have:

                $this->Post->unbindModel(array('hasMany' => array('Comment')));
                $this->Post->bindModel(array('hasMany' => array('Comment' =>
array('className' => 'Comment', 'fields' => array('count')))));

                $this->set('data', $this->Post->find('all', array('order' =>
'created DESC')));

I get the following error: "Unknown column 'Comment.count' in 'field
list'".

Where do I specify that I'm looking for just the count? I think in the
way I currently have it, it's trying to find a column called "count"
which doesn't exist.


On Nov 10, 1:57 am, francky06l <[EMAIL PROTECTED]> wrote:
> You bind your model again, using 'fields' option to set the fields you
> want :
>
> $this->Post->bindModel(array('hasMany' => array('Comment' =>
> array('className' => 'Comment',
>                                      'fields' => array('field you
> want'))));
>
> On Nov 10, 4:55 am, Action <[EMAIL PROTECTED]> wrote:
>
> > I want to be able to retrieve multiple blog posts as well as the
> > comment count for each post. I do not want to retrieve the comments
> > themselves, just the comment count.
>
> > This is what I have so far:
>
> > $this->Post->unbindModel(array('hasMany' => array('Comment')));
>
> > $this->set('data', $this->Post->find('all', array('order' => 'created
> > DESC')));
>
> > I unbound the model association so it wouldn't pull the comments in
> > the query. How can I make it so the find() as also grabs the comment
> > count for each post it is grabbing?
>
> > If I kept the association it would work, but I would have to also pull
> > all of the comment data as well, which is something I don't want to
> > do.
>
> > Thanks.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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