如何显示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:'登录帐号不存在互或密码错误!'}";
}
我登录了38次,均未成功(提示登录帐号不存在互或密码错误),log中也没提示错误。
为了帮助我核对数据,我要把sql语句,打印机出,如:select employeeno,password from
我使用vamp($model)
也显示不出来。
------解决方案--------------------开启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();
看看呢