ThinkPHP视图查询
一、总结
1、这里的视图查询和多表查询很像,当然多表查询的话肯定要支持左右链接查询
2、view:视图的使用,关键字是view
3、sql视图功能支持:thinkphp支持视图,也就是告诉我们,sql里面的视图,存储过程啥的thinkphp这些框架等都支持
二、ThinkPHP视图查询
$data=Db::view("goods","id,name,price")
->view("type",'name tname',"type.id=goods.cid")
->select();
// SELECT `goods`.`id`,`goods`.`name`,`goods`.`price`,type.name tname FROM `goods` `goods` INNER JOIN `type` `type` ON `type`.`id`=`goods`.`cid`
$data=Db::view("goods","id,name,price")
->view("type",'name tname',"type.id=goods.cid","left")
->select();
// SELECT `goods`.`id`,`goods`.`name`,`goods`.`price`,type.name tname FROM `goods` `goods` LEFT JOIN `type` `type` ON `type`.`id`=`goods`.`cid`