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_
版权声明:本文标题:两张数据表关联查询 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/dongtai/1730077639a1221987.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论