But 'count' returns only integer of value, and rest column?? And my first sql query returns this kl department_id 1 4 1 8 1 10
So only way is to create a own query?? $this->DepartmentBook->query(' SELECT count( * ) AS kl, ...'); 2011/7/6 Tilen Majerle <tilen.maje...@gmail.com>: > instead of "all" use "count" to get number of records from database :) > -- > Lep pozdrav, Tilen Majerle > http://majerle.eu > > > 2011/7/6 Dominik Gajewski <dominikgajews...@gmail.com> >> >> Hi >> >> I would like to count some rows but i can't print results of query >> exactly - count(*) AS kl - on the screen. >> >> this is my query, and there is no error >> $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' >> ) >> )); >> >> Only when i try to print on screen like that: >> for($i = 0; $i < count($res); $i++){ >> echo $res[$i]['DepartmentBook']['kl'].' >> '.$res[$i]['DepartmentBook']['department_id'].'<br>'; >> } >> >> it's showing me this: >> >> Notice (8): Undefined index: kl >> [APP\views\stats_months\current_graph.ctp, line 13] >> >> What should I type here $res[$i]['DepartmentBook']['?????'] >> >> -- >> 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 > > -- > 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 > -- 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