我有这样的查询 $ this-> find('all',$ query); 。如何在普通的php中获取此查询的结果数组?
答案 0 :(得分:0)
$this->getResultInNormalFormat($this->find('all',$query),array('alias1','alias2','alias2'));
function getResultInNormalFormat($query_result,$tables){
$extracted_array = array();
$i = TRUE;
foreach($tables as $table){
$extracted_arrays[] =Set::extract($query_result,'{n}.'.$table) ;
}
foreach($extracted_arrays as $extracted_array){
if($i){
$merged_array = (Set::merge($extracted_array));
}
else{
$merged_array = (Set::merge($extracted_array,$merged_array));
}
$i = FALSE;
}
return $merged_array;
}