Я использую Cakephp 2.2.4 , и мне нужно получить список Lead, который принадлежит пользователю ( id = 106 ).
Результатом запроса является:
array(
(int) 0 => array(
'Lead' => array(
'id' => '6',
'user_id' => '106',
'date' => '2012-12-31 22:15:23',
'ip' => '127.0.0.1',
'service_id' => '1',
'location' => 'Rome',
'message' => 'Message Message',
'telephone' => null,
'active' => null
),
'User' => array(
'id' => '106',
'email' => '[email protected]',
'pwd' => '0433c024cb08be13000d59a347e640482843f46f177e95749dc6599c259617fd3491dcb940b47693cbbc7f65a2cc5ef62deca2e600c1be133ad54170f7d1fbd1',
'role_id' => '3',
'active' => '1'
),
'Service' => array(
'id' => '1',
'name' => 'Primo servizio'
),
'Estimate' => array(
(int) 0 => array(
'id' => '1',
'lead_id' => '6',
'user_id' => '106'
)
)
)
)
Он выглядит хорошо, но мне нужно подсчитать Оценки (Оценка массива), я хотел бы получить количество оценок, а не массив со всеми полями (таблицы оценок).
Как мне это сделать?
Мне нужно :
Lead array as it shown
User array as it shown
Service array as it shown
Estimate (only the total number of the estimates... in this case 1
)
Находка очень проста:
$options = array('conditions' => array('User.id' => 106));
debug($this->Lead->find('all', $options));