我是从SQL查询创建对象的。
$result = mysqli_query($dbconnect,"SELECT SUM(value) AS total FROM `sales` WHERE `tdate` = CURDATE();");
我认为它应该将[' value]或[' total']传递给对象,但它似乎只会返回
{"current_field":null,"field_count":null,"lengths":null,"num_rows":null,"type":null}
这让我觉得查询本身返回NULL,因为没有找到结果,但是如果我在DB中运行查询,它会正确返回。有什么想法吗?
答案 0 :(得分:2)
您忘记了fetch
结果,请参阅下面的示例代码
$result = mysqli_query($dbconnect,"SELECT SUM(value) AS total FROM `sales` WHERE `tdate` = CURDATE();");
$data = mysqli_fetch_assoc($result);
var_dump($data);