原生sql简单的语句在thinkphp内执行,相信大家都是很熟悉了.
今天小编来介绍一下复杂的多表语句的实现
...
//统计总数
$sql = "select count(*) from table1 a left join table2 b on a.id=bi.id ";
$count = M()->excute($sql);
import('ORG.Util.Page');
$page = new Page($count,10);
$show = $page->show();
$list = M()->query("select a.id,b.id as bid,b.username from table1 a left join............. limit $page->firstRow,$page->listRows");
如此就实现了原生sql在TP中的应用.