如何以正常格式获取cakephp查询结果?

时间:2012-07-27 15:17:06

标签: cakephp

我有这样的查询 $ this-> find('all',$ query); 。如何在普通的php中获取此查询的结果数组?

1 个答案:

答案 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;
         }