buildSQL方法返回SQL语句,不执行查询。
$sql = $model->buildSQL();
echo $sql;
输出结果:
`select * from table`
* * * * *
$sql = $model2->where(array('id'=>1))->buildSQL();
$model1->where('id = ('. $sql .')')->select();
执行的SQL语句:`select * from table1 where id = (select * from table2 where id=1)`
上面的代码是通过buildSQL方法,实现连贯操作子查询。



