我试图从mysql表中提取所有行。 我已创建此代码
function getAllRows($tablename){
$query = $this->mysqli->prepare("SELECT * FROM `".$tablename."`");
$query->execute();
$query->bind_result($results);
while($query->fetch())
{
$rows[] = $results;
}
return $rows;
}
但是我发现了这个错误:
( ! ) Warning: mysqli_stmt::bind_result(): Number of bind variables doesn't match number of fields in prepared statement in D:\wamp64\www\easyApi\configuration.php on line 16
感谢您的帮助。
答案 0 :(得分:1)
您必须绑定与起诉选择的相同数量的列 你可以选择*返回更多列 尝试在bind_result中添加正确数量的var
$query = $this->mysqli->prepare("SELECT col1, col2 FROM `".$tablename."`");
...
$stmt->bind_result($col1, $col2);