Heim >Backend-Entwicklung >PHP-Tutorial > php 预编译查询始终fetch不到数据解决方案
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 />