我现在正在奋斗一个多小时,应该相当简单。
我想从我的mysqli数据库中获取行,当我从phpmyadmin运行我的查询时,我得到了预期的结果但是当我从我的php代码运行它(with bind_param
)时得到0结果:
$sql = $connection->prepare('SELECT (UNIX_TIMESTAMP(start_time))
FROM table1
WHERE UNIX_TIMESTAMP(start_time) >= ?
AND (UNIX_TIMESTAMP(start_time)) <= ?
AND column3 = ?')
or trigger_error($connection->error, E_USER_ERROR);
$sql->bind_param('sss', $value1, $value2, $value3);
$sql->execute() or trigger_error($sql->error, E_USER_ERROR);
if ($sql->num_rows == 0){
echo "yay";
}
答案 0 :(得分:1)
您需要存储MySQLi预处理语句的结果集。按如下方式调整代码:
interval
PHP文档:http://php.net/manual/en/mysqli-stmt.store-result.php http://php.net/manual/en/mysqli-stmt.num-rows.php