Home  >  Article  >  Backend Development  >  如何显示thinkphp执行的语句

如何显示thinkphp执行的语句

WBOY
WBOYOriginal
2016-06-23 13:58:131060browse

控制区器是这样写的

	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();

看看呢

加上 

$condition['_logic'] = 'AND'; 
$model = M("Employeeinfo");
$results = $model->where($condition)->select(); 
$model->getlastSql();

看看呢



这位兄台的才是正确的!

你select方法里面加上个false就好了。他就不执行SQL语句了。转而把SQL语句打印出来。
$model = M("Employeeinfo")->select( false);

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn