码迷,mamicode.com
首页 > 其他好文 > 详细

think 多表 分组三维数组

时间:2014-08-08 15:30:56      阅读:276      评论:0      收藏:0      [点我收藏+]

标签:style   color   os   io   数据   for   2014   ar   

public function businessDraftShow(){        
        $model = D(‘business‘);// 实例化Data数据对象
        $data = $model->search(2);
        $shuju = $data[‘data‘];
        $page = $data[‘page‘];
        $count = $data[‘count‘];
          foreach($shuju as $n => $val)  
            {  
                $bus_id = $shuju[$n][‘id‘];
               $shuju[$n][‘flow_all‘] =  M(‘flow‘)->where(array(‘business_id‘ => $bus_id)) -> select();    
               $shuju[$n][‘comment_all‘] =  M(‘comment‘)->where(array(‘business_id‘ => $bus_id)) -> select();          
            //show_bug($n);
            }  
                        
        show_bug($shuju);
        
        $this->assign(‘data‘, $shuju);
        $this->assign(‘page‘, $page);
        $this->assign(‘count‘, $count);
        
        $type_array = array(‘0‘=>‘请选择‘,‘1‘ => ‘房产抵押‘,‘2‘=>‘车辆抵押‘,‘3‘=>‘其他业务‘);
        $business_node = array(‘0‘=>‘未提交受理‘,‘1‘=>‘已经退回‘,‘2‘=>‘已经受理‘);
        
        
        $this->assign(‘type_array‘,$type_array);
                
        $this->assign(‘business_node‘,$business_node);
        
        $this->display();
    }

 

这里是得到一个id,让后用这个id查别的表,然后添加到数组里面,assign到模板

结果是一个三维数组,我实在是用多表查不出来,希望大家给予帮助和指出

 

array(5) {
  [0]=>
  array(13) {
    ["id"]=>
    string(2) "30"
    ["business_num"]=>
    string(19) "DDZC-20140807183038"
    ["business_name"]=>
    string(12) "阿斯顿飞"
    ["business_type"]=>
    string(1) "0"
    ["proposer"]=>
    string(9) "张无忌"
    ["proposer_time"]=>
    string(19) "2014-08-07 18:30:38"
    ["special_state"]=>
    string(0) ""
    ["Accept_people"]=>
    string(0) ""
    ["Accept_time"]=>
    string(19) "0000-00-00 00:00:00"
    ["Accept_state"]=>
    string(0) ""
    ["node"]=>
    string(1) "1"
    ["flow_all"]=>
    array(3) {
      [0]=>
      array(8) {
        ["id"]=>
        string(2) "43"
        ["business_id"]=>
        string(2) "30"
        ["flow_id"]=>
        string(1) "0"
        ["flow_node"]=>
        string(1) "0"
        ["flow_time"]=>
        string(19) "2014-08-07 20:14:34"
        ["flow_people"]=>
        string(9) "业务员"
        ["flow_result"]=>
        string(1) "1"
        ["flow_state"]=>
        string(23) "
退回你太难看了"
      }
      [1]=>
      array(8) {
        ["id"]=>
        string(2) "44"
        ["business_id"]=>
        string(2) "30"
        ["flow_id"]=>
        string(1) "0"
        ["flow_node"]=>
        string(1) "0"
        ["flow_time"]=>
        string(19) "2014-08-08 09:16:51"
        ["flow_people"]=>
        string(9) "业务员"
        ["flow_result"]=>
        string(1) "1"
        ["flow_state"]=>
        string(14) "
阿斯顿飞"
      }
      [2]=>
      array(8) {
        ["id"]=>
        string(2) "45"
        ["business_id"]=>
        string(2) "30"
        ["flow_id"]=>
        string(1) "0"
        ["flow_node"]=>
        string(1) "0"
        ["flow_time"]=>
        string(19) "2014-08-08 10:36:30"
        ["flow_people"]=>
        string(9) "业务员"
        ["flow_result"]=>
        string(1) "1"
        ["flow_state"]=>
        string(18) "
这个也难看2"
      }
    }
    ["comment_all"]=>
    NULL
  }
  [1]=>
  array(13) {
    ["id"]=>
    string(2) "29"
    ["business_num"]=>
    string(19) "DDZC-20140807105706"
    ["business_name"]=>
    string(12) "我的业务"
    ["business_type"]=>
    string(1) "0"
    ["proposer"]=>
    string(9) "张无忌"
    ["proposer_time"]=>
    string(19) "2014-08-07 10:57:06"
    ["special_state"]=>
    string(0) ""
    ["Accept_people"]=>
    string(0) ""
    ["Accept_time"]=>
    string(19) "0000-00-00 00:00:00"
    ["Accept_state"]=>
    string(0) ""
    ["node"]=>
    string(1) "1"
    ["flow_all"]=>
    array(1) {
      [0]=>
      array(8) {
        ["id"]=>
        string(2) "47"
        ["business_id"]=>
        string(2) "29"
        ["flow_id"]=>
        string(1) "0"
        ["flow_node"]=>
        string(1) "0"
        ["flow_time"]=>
        string(19) "2014-08-08 11:41:20"
        ["flow_people"]=>
        string(9) "业务员"
        ["flow_result"]=>
        string(1) "1"
        ["flow_state"]=>
        string(14) "阿斯顿飞
"
      }
    }
    ["comment_all"]=>
    NULL
  }
  [2]=>
  array(13) {
    ["id"]=>
    string(2) "27"
    ["business_num"]=>
    string(19) "DDZC-20140805105045"
    ["business_name"]=>
    string(9) "撒旦发"
    ["business_type"]=>
    string(1) "1"
    ["proposer"]=>
    string(9) "张无忌"
    ["proposer_time"]=>
    string(19) "2014-08-05 10:50:45"
    ["special_state"]=>
    string(12) "阿斯顿飞"
    ["Accept_people"]=>
    string(0) ""
    ["Accept_time"]=>
    string(19) "0000-00-00 00:00:00"
    ["Accept_state"]=>
    string(0) ""
    ["node"]=>
    string(1) "0"
    ["flow_all"]=>
    NULL
    ["comment_all"]=>
    NULL
  }
  [3]=>
  array(13) {
    ["id"]=>
    string(2) "26"
    ["business_num"]=>
    string(19) "DDZC-20140730103651"
    ["business_name"]=>
    string(5) "asdf "
    ["business_type"]=>
    string(1) "0"
    ["proposer"]=>
    string(9) "张无忌"
    ["proposer_time"]=>
    string(19) "2014-07-30 10:36:51"
    ["special_state"]=>
    string(4) "asf "
    ["Accept_people"]=>
    string(0) ""
    ["Accept_time"]=>
    string(19) "0000-00-00 00:00:00"
    ["Accept_state"]=>
    string(0) ""
    ["node"]=>
    string(1) "1"
    ["flow_all"]=>
    array(2) {
      [0]=>
      array(8) {
        ["id"]=>
        string(2) "15"
        ["business_id"]=>
        string(2) "26"
        ["flow_id"]=>
        string(1) "0"
        ["flow_node"]=>
        string(1) "0"
        ["flow_time"]=>
        string(19) "2014-07-30 15:23:29"
        ["flow_people"]=>
        string(9) "业务员"
        ["flow_result"]=>
        string(1) "2"
        ["flow_state"]=>
        string(14) "
阿斯顿飞"
      }
      [1]=>
      array(8) {
        ["id"]=>
        string(2) "46"
        ["business_id"]=>
        string(2) "26"
        ["flow_id"]=>
        string(1) "0"
        ["flow_node"]=>
        string(1) "0"
        ["flow_time"]=>
        string(19) "2014-08-08 11:41:02"
        ["flow_people"]=>
        string(9) "业务员"
        ["flow_result"]=>
        string(1) "1"
        ["flow_state"]=>
        string(14) "
阿斯顿飞"
      }
    }
    ["comment_all"]=>
    NULL
  }
  [4]=>
  array(13) {
    ["id"]=>
    string(2) "25"
    ["business_num"]=>
    string(19) "DDZC-20140727202724"
    ["business_name"]=>
    string(9) "撒旦发"
    ["business_type"]=>
    string(1) "1"
    ["proposer"]=>
    string(9) "张无忌"
    ["proposer_time"]=>
    string(19) "2014-07-27 20:27:24"
    ["special_state"]=>
    string(9) "撒旦发"
    ["Accept_people"]=>
    string(0) ""
    ["Accept_time"]=>
    string(19) "0000-00-00 00:00:00"
    ["Accept_state"]=>
    string(9) "撒旦发"
    ["node"]=>
    string(1) "1"
    ["flow_all"]=>
    array(7) {
      [0]=>
      array(8) {
        ["id"]=>
        string(1) "1"
        ["business_id"]=>
        string(2) "25"
        ["flow_id"]=>
        string(1) "0"
        ["flow_node"]=>
        string(1) "0"
        ["flow_time"]=>
        string(19) "2014-07-29 17:08:17"
        ["flow_people"]=>
        string(9) "业务员"
        ["flow_result"]=>
        string(1) "1"
        ["flow_state"]=>
        string(14) "你太坏了
"
      }
      [1]=>
      array(8) {
        ["id"]=>
        string(1) "2"
        ["business_id"]=>
        string(2) "25"
        ["flow_id"]=>
        string(1) "0"
        ["flow_node"]=>
        string(1) "0"
        ["flow_time"]=>
        string(19) "2014-07-29 17:09:06"
        ["flow_people"]=>
        string(9) "业务员"
        ["flow_result"]=>
        string(1) "1"
        ["flow_state"]=>
        string(14) "
这个不行"
      }
      [2]=>
      array(8) {
        ["id"]=>
        string(1) "3"
        ["business_id"]=>
        string(2) "25"
        ["flow_id"]=>
        string(1) "0"
        ["flow_node"]=>
        string(1) "0"
        ["flow_time"]=>
        string(19) "2014-07-29 17:11:40"
        ["flow_people"]=>
        string(9) "业务员"
        ["flow_result"]=>
        string(1) "1"
        ["flow_state"]=>
        string(14) "
阿斯顿飞"
      }
      [3]=>
      array(8) {
        ["id"]=>
        string(1) "4"
        ["business_id"]=>
        string(2) "25"
        ["flow_id"]=>
        string(1) "0"
        ["flow_node"]=>
        string(1) "0"
        ["flow_time"]=>
        string(19) "2014-07-29 17:11:45"
        ["flow_people"]=>
        string(9) "业务员"
        ["flow_result"]=>
        string(1) "2"
        ["flow_state"]=>
        string(17) "
行就这样吧"
      }
      [4]=>
      array(8) {
        ["id"]=>
        string(1) "5"
        ["business_id"]=>
        string(2) "25"
        ["flow_id"]=>
        string(1) "0"
        ["flow_node"]=>
        string(1) "0"
        ["flow_time"]=>
        string(19) "2014-07-29 17:37:25"
        ["flow_people"]=>
        string(9) "业务员"
        ["flow_result"]=>
        string(1) "1"
        ["flow_state"]=>
        string(2) "
"
      }
      [5]=>
      array(8) {
        ["id"]=>
        string(1) "9"
        ["business_id"]=>
        string(2) "25"
        ["flow_id"]=>
        string(1) "0"
        ["flow_node"]=>
        string(1) "0"
        ["flow_time"]=>
        string(19) "2014-07-29 18:10:30"
        ["flow_people"]=>
        string(9) "业务员"
        ["flow_result"]=>
        string(1) "2"
        ["flow_state"]=>
        string(2) "
"
      }
      [6]=>
      array(8) {
        ["id"]=>
        string(2) "11"
        ["business_id"]=>
        string(2) "25"
        ["flow_id"]=>
        string(1) "0"
        ["flow_node"]=>
        string(1) "0"
        ["flow_time"]=>
        string(19) "2014-07-30 10:29:29"
        ["flow_people"]=>
        string(9) "业务员"
        ["flow_result"]=>
        string(1) "2"
        ["flow_state"]=>
        string(2) "
"
      }
    }
    ["comment_all"]=>
    NULL
  }
}

think 多表 分组三维数组,布布扣,bubuko.com

think 多表 分组三维数组

标签:style   color   os   io   数据   for   2014   ar   

原文地址:http://www.cnblogs.com/cnitc/p/3899174.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!