编辑:添加了PDO调用。
这是实际错误:
Notice: Object of class PDOStatement could not be converted to int in Unknown on line 0
我通常如何找出错误/通知的正确行,因为它不是line 0
?
我尝试使用register_tick_function回显 file:line,这不起作用,因为通知总是在我的总输出结束时输出。
我正在寻找一种通用的调试方法,因为我在该对象的类中找不到任何错误。
// PHP PDO Standard
$db_server = 'mysql:host='.$this->db_host.';dbname='.$this->db_dbase;
try {
$this->db_connection = new PDO($db_server, $this->db_user, $this->db_pass);
$pdo_set = $this->db_connection->setAttribute(PDO::ATTR_EMULATE_PREPARES, FALSE);
$pdo_set = $this->db_connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$pdo_set = $this->db_connection->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
//DebugPrint($pdo_set, '$pdo_set');
} catch (PDOException $e) {
//print 'Error!: '.$e->getMessage().'<br/>';
die();
}
最后,我找到了自己的问题的答案:
// doing PDO-sql, inserting session data, I ran into my problem.
$this->db_connection = new PDO(...);
$sql_query = "INSERT INTO ".$this->session_db_table." (...) VALUES (...)";
$sql_result = $this->db_connection->query($sql_query);
// This is the line (ideally named "0") from the notice:
return $sql_result;
return $sql_result
抛出这个通知:
"注意:无法将类 PDOS 的对象转换为第 0 行的未知中的 int">
$sql_result
是一个object
;预期的返回格式似乎boolean
。
所以我删除了这个return
通知现在消失了。
我有一段时间了这个问题,并通过重新启动 (w(AMP 修复了这个问题。
我唯一的猜测是扩展没有正确加载。
就我而言,我得到了:
MongoDB''Model''BSONDocument::getiterator in Unknown on line 0