我在服务器上添加了一个CMS。我只是想知道为什么我在购买订阅的页面上总是出现这个错误。
这就是错误;
Catchable fatal error: Argument 1 passed to ObjectArray::fromMySQLiResult() must be an instance of
mysqli_result, boolean given, called in
C:'inetpub'wwwroot'model'FactoryObjects'User.php on line 71
and defined in C:'inetpub'wwwroot'lib'ObjectArray.php on line 284
第71行包含以下内容:;
public function getOrders() {
$objectArray = new ObjectArray();
$result = $this->getConnection()->query("SELECT * FROM vip_orders WHERE user_id =
'" . $this->id. "'");
$objectArray->fromMySQLiResult($result); (<Line 71<)
return $objectArray;
}
第284行包含以下内容:;
public function fromMySQLiResult(mysqli_result $result) (<Line 284<)
{
$this->clear();
while ($row = $result->fetch_object())
{
$this->add($row);
}
return $this;
}
请让我知道,如果有任何其他信息是必要的,你可以帮助我解决这个错误!
谢谢!
(注意:对于那些提供帮助的人,你能解释一下到底是什么问题吗?例如,功能是什么以及为什么不起作用,谢谢。)
您对fromMySQLiResult(mysqli_result $result)
的定义指出,函数需要类型为mysqli_result
的参数。但是,您正在传递mysqli::query()的结果,如果失败,该结果也可能是布尔类型的。
为了防止出现错误,请确保$result
实际上是一个类似于文档中示例的查询结果:
if ($result) {
$objectArray->fromMySQLiResult($result);
} else {
// handle error
}