如何获得正常格式的cakephp查询结果?
答
$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;
}
我强烈建议您学习如何处理CakePHP为它们提供的格式的结果 - 从长远来看,它会让事情变得更容易。 – JJJ 2012-07-27 15:24:11
你能否详细说明一下? – tyjkenn 2012-07-27 20:20:45