我目前正在使用Word press应用程序。当应用程序尝试插入数据库时,其中一种方法失败。但是,当我记录错误时,Docker日志上没有显示任何内容。
如果无法登录服务器,则很难调试。
<?php
namespace StatCollector;
function drools_request($data, $uid) {
try {
$db = _get_db();
$insertion = $db->insert("requests", [
"uid" => $uid,
"data" => json_encode($data),
]);
error_log(print_r($insertion,true));
if( $insertion === false ) {
throw new \Exception('Error writing to the database: ');
}
}
catch(\Exception $e) {
echo 'Error writing to the database: ', $e->getMessage(), "\n";
}
}
这里我尝试error_log(print_r($insertion,true));
也没有成功,echo 'Error writing to the database: '
也没有成功,但是没有任何内容登录到服务器。如何登录服务器?
为什么异常不是catch
?这是一场噩梦。