OK, here is my table/model structure: Models are associated approprately.

I am trying to query the sum of holding value for a given client id, with the date for a given sum of value as the array key.
I having consulted the docs I have produced the following parameters for my query in the Client model:
$findParameters = array(
'conditions' => array(
'Account.client_id' => $clientId,
'Holding.holding_date = LAST_DAY(Holding.holding_date)', //gets month-end dates only
'MONTH(Holding.holding_date)' => array(3,6,9,12) //Use for quarter-end dates
),
'fields' => array(
'Holding.holding_date',
'SUM(Holding.value) AS portfolio_value'
),
'group' => array('Holding.holding_date')
);
When I run the query by doing
$holdings = $this->Account->Holding->find( 'all', $findParameters );
I get a result like this:
Array
(
[0] => Array
(
[Holding] => Array
(
[holding_date] => 2009-12-31
)
[0] => Array
(
[portfolio_value] => 273239.07
)
)
[1] => Array
(
[Holding] => Array
(
[holding_date] => 2010-03-31
)
[0] => Array
(
[portfolio_value] => 276625.28
)
)
...
Which is great but I want the result in an array like this:
Array (
[2009-12-31] => 273239.07
[2010-03-31] => 276625.28
...
)
So I try doing:
$holdings = $this->Account->Holding->find( 'list', $findParameters )
But I get the error:
Error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'Account.client_id' in 'where clause'
The query looks as if it is no longer performing the joins on the tables. Any idea why, given it works fine if I use all instead of list? And how to get my desired result?
EDIT: I have acheived my result using Cake's hash class but was wondering if a direct query is a superior and more efficient method.
My method:
$holdings = $this->Account->Holding->find( 'all', $findParameters );
$values = Hash::extract($result, '{n}.0.portfolio_value');
$dates = Hash::extract($result, '{n}.Holding.holding_date');
$result = array_combine($dates, $values);
return $result;
Hash::combineis doing what you do : 2 extract and one combine.