You can also use a virtualField in the DepartmentBook model. The virtualFields end up indexed into the correct array as if they were real fields - this means you don't have to shuffle your results around before using the data.
I put together a little gist showing what I mean. https://gist.github.com/1073889 Hope this helps. On Jul 8, 8:48 am, Dominik Gajewski <dominikgajews...@gmail.com> wrote: > Thanks for your reply > > 2011/7/8 Dr. Loboto <drlob...@gmail.com>: > > > > > > > > > > > In case of > > $res = $this->DepartmentBook->find('all', array( > > > 'fields' => array( > > > 'count(*) AS kl', > > > 'DepartmentBook.department_id' > > ), > > > 'conditions' => array( > > > 'DepartmentBook.extract_date' => null, > > ), > > > 'order' => array( > > > 'DepartmentBook.department_id' > > ), > > > 'group' => array( > > > 'DepartmentBook.department_id' > > ) > > )); > > You'll have your count under $res[$i][0]['kl'] - NOT $res[$i] > > ['DepartmentBook']['kl']. Result of aggregate function does not belong > > to source table and resides under "unknown" index. > > > All such problems can be solved by simple output of array to look into > > its structure. > > > -- > > Our newest site for the community: CakePHP Video > > Tutorialshttp://tv.cakephp.org > > Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help > > others with their CakePHP related questions. > > > To unsubscribe from this group, send email to > > cake-php+unsubscr...@googlegroups.com For more options, visit this group > > athttp://groups.google.com/group/cake-php > > -- > Pozdrawiam > Dominik Gajewski -- 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php