Home  >  Article  >  Backend Development  >  怎么显示thinkphp执行的语句

怎么显示thinkphp执行的语句

WBOY
WBOYOriginal
2016-06-13 13:00:381431browse

如何显示thinkphp执行的语句
控制区器是这样写的

	function checkLogin(){<br />
<br />
		$condition['employeeno'] = $_REQUEST['employeeno'];<br />
		$condition['password'] = $_REQUEST['password'];<br />
<br />
		$model = M("Employeeinfo");<br />
		$results = $model->where($condition)->select(); <br />
		sql($model);<br />
	<br />
		if($results){<br />
			if(trim($results[0]['Password'])==$condition['password']){<br />
				echo "{success:true,msg:'OK'}";<br />
				Session::set('employeeno','employeeno');<br />
				Session::set('userinfo',$results[0]);<br />
				return;<br />
			}<br />
		}<br />
		echo "{success:true,msg:'登录帐号不存在互或密码错误!'}";<br />
	}


我登录了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();

看看呢

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