Rumah > Artikel > pembangunan bahagian belakang > 如何显示thinkphp执行的语句
控制区器是这样写的
function checkLogin(){ $condition['employeeno'] = $_REQUEST['employeeno']; $condition['password'] = $_REQUEST['password']; $model = M("Employeeinfo"); $results = $model->where($condition)->select(); sql($model); if($results){ if(trim($results[0]['Password'])==$condition['password']){ echo "{success:true,msg:'OK'}"; Session::set('employeeno','employeeno'); Session::set('userinfo',$results[0]); return; } } echo "{success:true,msg:'登录帐号不存在互或密码错误!'}"; }
开启debug,检查sql语句,复制sql语句在数据库中执行,看看有没有结果
$model = M("Employeeinfo");
$results = $model->where($condition)->select();
echo $results->getlastSql();
加上
$condition['_logic'] = 'AND';
$model = M("Employeeinfo");
$results = $model->where($condition)->select();
$model->getlastSql();
看看呢
加上
$condition['_logic'] = 'AND';
$model = M("Employeeinfo");
$results = $model->where($condition)->select();
$model->getlastSql();
看看呢
你select方法里面加上个false就好了。他就不执行SQL语句了。转而把SQL语句打印出来。
$model = M("Employeeinfo")->select( false);