Home  >  Article  >  Backend Development  >  php 预编译查询始终fetch不到数据解决方案

php 预编译查询始终fetch不到数据解决方案

WBOY
WBOYOriginal
2016-06-13 11:33:19925browse

php 预编译查询始终fetch不到数据

<br />include ('../db/MySqlConnect.php');<br />$conn = new MySqlConnect();<br />$mysqli = $conn->getConnection();<br />$sql = 'select id, username, password from admin where id = ?';<br />$seach_id = 1;<br />settype($seach_id, "integer");<br />if($stmt = $mysqli->prepare($sql)) {<br />	$stmt->bind_param('i', $seach_id);<br />	$stmt->execute();<br />	$stmt->bind_result($rs_id, $rs_name, $rs_password);<br />	if($stmt->fetch() == NULL) {<br />		echo 'no result';<br />	} else {<br />		 printf('id:%s, name:%s, password:%s <br/>', $rs_id, $rs_name, $rs_password);<br />	}<br />	$stmt->close();<br />	$mysqli->close();<br />}<br />

SQL语句明明可以查询出来数据, 我使用PHP的非预编译语句($result = $mysqli->query($query);)也可以查询出来记录, 就是上面的查询代码始终在fetch出抓取不到数据,我的PHP版本是php-5.2.5-x64, 环境是64位的Win7, 有遇到过的朋友或知道的能给分析一下么, 我已经困扰2天了....谢谢了

php prepare fetch
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