IndexController.class.php
[PHP] 纯文本查看 复制代码 <?php
namespace Models\Controller;
use Think\Controller;
class IndexController extends Controller {
public function index(){
$userModel = D('user');
// 字符串方式
dump ($userModel->where('status = 0')->select());
dump ($userModel->getLastSql());
// 数组方式
$condition = array(
'age' => 0,
'status' => 0
);
// order排序、limit筛选从m条开始的第n条,page则自动计算转成limit
dump($userModel->where($condition)->order('id desc')->limit(2,3)->select());
dump($userModel->where($condition)->order('id desc')->page(6,10)->select());
// 包含fetchSql则只返回SQL语句,不做其他操作
dump($userModel->where($condition)->order('id desc')->page(6,10)->fetchSql(true)->select());
dump ($userModel->getLastSql());
}
}
|