我有一个HABTM模型Request HABTM Certificates
当我$this->Request->find('all)
时,我得到了这个数组:
(int) 0 => array(
'Request' => array(
'id' => '114',
'motivo' => 'Licitação',
'status' => false,
'solicitante' => ''
),
'Certificate' => array(
(int) 0 => array(
'id' => '1',
'nome' => '545.15',
'responsavel' => '123',
'email' => 'eu@vc.com',
'emailcc' => '',
'CertificatesRequest' => array(
'id' => '53',
'request_id' => '114',
'certificate_id' => '1'
)
),
(int) 1 => array(
'id' => '3',
'nome' => 'Certidao',
'responsavel' => '10',
'email' => 'eu@vc.com',
'emailcc' => '',
'CertificatesRequest' => array(
'id' => '54',
'request_id' => '114',
'certificate_id' => '3'
)
)....
我需要list
Certificates.nome
对应某个Request.id
。
我正在尝试这个,没有成功:
$arquivos = $this->Request->find('list', array('conditions' => array('id' => 114),
'contain' => array('Certificate' => array('fields' => array('nome')))));
如何list
Certificates.nome
对应某个Request.id
。
答案 0 :(得分:0)
试试这个:
$arquivos = $this->Request->Certificate->find('list', array(
'conditions' => array('Request.id' => 114),
'fields' => array('Certificate.id', 'Certificate.nome')
));
答案 1 :(得分:0)