mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
...
try {
$result = $this->link->real_escape_string(
$this->link->query($query)
);
} catch (Exception $e) {
Service::error($e);
}
return $result;
// 以上应该绝对有效。下面的选项会起作用吗?如果是的话,不知何故评论一下,触发异常的原理不是很清楚。
try {
return $this->link->real_escape_string(
$this->link->query($query)
);
} catch (Exception $e) {
Service::error($e);
}
触发Exception的原理很简单:
必要时抛出Exception,并捕获catch中抛出的内容。
我建议您在 Google 中更详细地搜索短语“php exception”。关于这个主题有https://habrahabr.ru/post/264417/。