Hi,
i am having a action like
$report_attrid=$this->Report->find('all',array('conditions'=>array('Report.report_id'=>$report_id,'Report.user_id'=>$userId)));
foreach($report_attrid as & $reportattrid):
$reportattrid['Report']['value']=$this->Result->find('all',array('fields'=>array('Result.label','Result.value','Result.submitter_id','Result.submitter'),'conditions'=>array('Result.attribute_id'=>$reportattrid['Report']['attribute_id'],'Result.form_id'=>$report_form_id),'order'=>'Result.id'));//returns 2 rows for each attribute id
endforeach;
$this->set('Report_attrid',$report_attrid);
where $reportattrid['Report']['value'] while executing in the debug mode executes as
SELECT Result
.label
, Result
.value
, Result
.submitter_id
, Result
.submitter
FROM results
AS Result
WHERE Result
.attribute_id
= 69 AND Result
.form_id
= 24 ORDER BY Result
.id
ASC => gives 2 rows
SELECT Result
.label
, Result
.value
, Result
.submitter_id
, Result
.submitter
FROM results
AS Result
WHERE Result
.attribute_id
= 72 AND Result
.form_id
= 24 ORDER BY Result
.id
ASC => another 2 rows
But while displaying it gives one row from the first query and 1 row second query..
Report table has(id,report_id,title,attribute_id)
Result table has(id,attribute_id,form_id,label,value,submitter_id)
Attribute(id,label,value)
i am trying to fetch the value for each attribute id of the Report..
but i am getting only the last row for each execution/.. why so suggest me.