0

我正在尝试获取列 dateTime 的值,然后使用这些值获取当天的条目数。所以我将一个数组传递给bind_param。但在这里我得到了错误:

“mysqli_stmt_bind_param() 的参数 3 应作为参考”

我也尝试了似乎也不起作用的注释方法。这是代码:

<?php
$hostname = "localhost";
$database = "ti_project";
$username = "root";
$password = "";
$mysqli = new mysqli($hostname, $username, $password, $database);

$query = "SELECT dateTime FROM feedback";
$result = $mysqli->prepare($query);
/*$result->bind_param('s', $datetime);*/
$result->execute();

$result->bind_result($Date);

while ($result->fetch()){
 $feedbackdate[] = array($Date);
}

$type="s";
$query = "SELECT COUNT(*) FROM feedback WHERE dateTime = ?";
$result = $mysqli->prepare($query);
call_user_func_array('mysqli_stmt_bind_param', 
                array_merge (array($result, $type),$feedbackdate));

$result->execute();


/*$ref    = new ReflectionClass('mysqli_stmt'); 
$method = $ref->getMethod("bind_param"); 
$method->invokeArgs($result,$feedbackdate); 
$result->execute(); 
*$result->bind_*result($count);*/

while ($result->fetch()){
    $Count[] = array(
    'Count' => $count
);
}
echo json_encode($Count);

$result->close();

$mysqli->close();

?>
4

1 回答 1

0

函数调用中缺少语句变量。此函数接受 3 个参数而不是 2 个。您缺少提供准备好的语句。

call_user_func_array('mysqli_stmt_bind_param', $stmt, array_merge (array($result, $type), $feedbackdate));

请在此处阅读 mysqli_stmt_bind_param 函数参考

于 2016-01-21T07:34:46.667 回答