Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/229.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php PDO:对成员函数errorInfo()的调用_Php_Mysql_Pdo - Fatal编程技术网

Php PDO:对成员函数errorInfo()的调用

Php PDO:对成员函数errorInfo()的调用,php,mysql,pdo,Php,Mysql,Pdo,我读过关于PDO的书。我出错,尝试了errorInfo()函数。 但是,我在尝试使用errorInfo()时遇到此错误: 我在教程中使用了以下代码: $query = $db->query('SELECT * FROM notexistingtable'); //that was the error I had if (!$query) { var_dump($query->errorInfo()); } 那么-如果我有这样的错误,我如何正确使用errorInfo()函数呢?

我读过关于PDO的书。我出错,尝试了errorInfo()函数。 但是,我在尝试使用errorInfo()时遇到此错误:

我在教程中使用了以下代码:

$query = $db->query('SELECT * FROM notexistingtable'); //that was the error I had 

if (!$query) {
var_dump($query->errorInfo());
} 
那么-如果我有这样的错误,我如何正确使用errorInfo()函数呢?

请参见:errorInfo是一种PDO方法(这里的实例是
$db
),而不是由失败的查询返回的
false

因此,使用
$db->errorInfo()
获取故障信息。

您不需要errorInfo()函数。
$query = $db->query('SELECT * FROM notexistingtable'); //that was the error I had 

if (!$query) {
var_dump($query->errorInfo());
}