4 回答
TA贡献1856条经验 获得超5个赞
因此,如果MySQL本机驱动程序(mysqlnd)驱动程序不可用,因此使用bind_result和fetch而不是get_result,代码将变为:
include 'conn.php';
$conn = new Connection();
$query = 'SELECT EmailVerified, Blocked FROM users WHERE Email = ? AND SLA = ? AND `Password` = ?';
$stmt = $conn->mysqli->prepare($query);
$stmt->bind_param('sss', $_POST['EmailID'], $_POST['SLA'], $_POST['Password']);
$stmt->execute();
$stmt->bind_result($EmailVerified, $Blocked);
while ($stmt->fetch())
{
/* Use $EmailVerified and $Blocked */
}
$stmt->close();
$conn->mysqli->close();
TA贡献1836条经验 获得超5个赞
你的系统缺少mysqlnd驱动程序!
如果您能够在(基于Debian / Ubuntu的)服务器上安装新软件包,请安装驱动程序:
sudo apt-get install php5-mysqlnd
然后重新启动您的Web服务器:
sudo /etc/init.d/apache2 restart
TA贡献1804条经验 获得超2个赞
对于那些搜索$ result = stmt-> get_result()的替代方法的人我已经创建了这个函数,它允许你模仿$ result-> fetch_assoc()但直接使用stmt对象:
function fetchAssocStatement($stmt){ if($stmt->num_rows>0) { $result = array(); $md = $stmt->result_metadata(); $params = array(); while($field = $md->fetch_field()) { $params[] = &$result[$field->name]; } call_user_func_array(array($stmt, 'bind_result'), $params); if($stmt->fetch()) return $result; } return null;}
正如你所看到它创建一个数组并使用行数据获取它,因为它在内部使用$ stmt-> fetch(),你可以像调用mysqli_result :: fetch_assoc一样调用它(只需确保$ stmt对象)打开并存储结果):
//mysqliConnection is your mysqli connection objectif($stmt = $mysqli_connection->prepare($query)){ $stmt->execute(); $stmt->store_result(); while($assoc_array = fetchAssocStatement($stmt)) { //do your magic } $stmt->close();}
希望这可以帮助。
添加回答
举报