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.
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(
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(
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
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
I solved this problem. Maybe it is more complicated but it works
$res = $this-DepartmentBook-find('all', array(
'fields' = array(
'count(*) AS kl',
'DepartmentBook.department_id',
'DepartmentBook.id'
),
'conditions' = array(