PDO查询不返回对象



我试图对数据库运行查询,但PDO没有产生任何结果。

这是有效的。

$coon = new PDO("mysql:host=localhost;port=3308;dbname=developer", "root", "");
$fetch = $coon->query("SELECT * FROM users");
var_dump($fetch->fetch());

上面的代码总是返回真实的

public static function query($statement, $data = null)
{
$connection = self::get_connection();
if(!$data)
return $connection->query($statement);
$stmt = $connection->prepare($statement);
return $stmt->execute($data);
}

这种方式总是返回CCD_ 1而不是PDO查询对象。

我已经尝试使用try/catch块来查看是否有任何错误。。但什么都没有。

我不知道它可能是什么,因为显然一切都是正确的。

execute返回truefalse

您的PDOStatement object(结果对象,PDO查询对象(是$stmt

最新更新