$business_type = D("business_type");
$types = $business_type->alias('bt')
->field('bt.id,bt.type_name,bt.picture_id,bt.sort,bt.status,p.path')
->join('left join lg_picture p on bt.picture_id = p.id')
->where('bt.status = 1')
->select();
这个是怎么做到一次查询可以将俩个表的数据拿出来
这个叫做链式写法。因为,对象里面的方法可以return 对象
具体问题可以看这个
SQL链式写法
http://.com/a/1190000003069921
SELECT * FROM table a LEFT JOIN table b ON a.id = b.id
其实就是这个关联SQL查询语句
mysql是join关联表。
thinkPHP框架以链式调用的方式拼凑对应的sql语句。
请先了解一下 MySQL 中关联查询。