admin管理员组

文章数量:1667252

笔记一、多表查询
    两张表通过关联字段将一张表的company.name赋值给customer.origin

    我的思路:
        1、使用model查询将数据查询出来,查询结果为数二维组;
            $customer_model = model('Customer');
            $csr_get = $customer_model->get($value['id']);
        2、通过foreach将查讯的结果遍历为一维数组;
            foreach ($csr_all_toArray as $key => $value) {}
        3、将company中的数据通过模型查询出来,然后嵌套在foreach中,再次遍历;
        4、将遍历的数据赋值给$csr_get['origin'];
            $csr_get['origin'] = $origin_res['name']
        5、打印输出结果为一维数组;
            dump($csr_res);
        6、将一维数组转换为二维数组渲染到视图上。

    我的问题:
        一维数组转二维数组

    解决方案:
        使用model查询,将查询结果遍历:
        //获取关联的两张数据表
        $customer_model = model('Customer');
        $company_model = model('Company');
        $csr_all_

本文标签: 两张数据表