You can try that :
array('fields'=>array('*', '(COUNT (*)) AS QuestionsTag.count')
On 10 fév, 08:41, seedifferently <[email protected]> wrote:
> Dear group,
>
> I've got a questions_tags table that has a column for the tag_id and
> question_id. I want to do a proper CakePHP model find('all') query to
> pull the tag_id's with the related COUNT for each time a tag_id is
> used.
>
> So far I can do this:
>
> $this->QuestionsTag->find('all', array('fields'=>array('*', '(COUNT
> (*)) AS count'), 'group'=>'tag_id'));
>
> However, the output is this:
>
> Array
> (
> [QuestionsTag] => Array
> (
> [tag_id] => 3
> [question_id] => 1
> [created] => 0000-00-00 00:00:00
> [updated] => 0000-00-00 00:00:00
> )
>
> [Tag] => Array
> (
> [id] => 3
> [title] => testtag
> [created] => 0000-00-00 00:00:00
> [updated] => 2009-02-09 16:26:15
> )
>
> [0] => Array
> (
> [count] => 2
> )
>
> )
>
> How can I get the $array[0][count] up there in the $array[QuestionsTag]
> ['count'] where it belongs? Why is it out there by itself under an
> index of 0?
>
> Thanks,
> Seth
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---