Nitish Nitish - 6 months ago 37
MySQL Question

PDO returns empty object

I have a connection as below :

$dsn = 'mysql: host=localhost; dbname=ami';
$user = 'root';
$password = 'password';
try {
$pdo = new PDO($dsn, $user, $password); var_dump($pdo);
catch (PDOException $e) {
echo 'Connection failed: ' . $e->getMessage();

But the output is
object(PDO)#1 (0) { }
. I am clueless whats wrong !


It is not an empty object. var_dump is showing you less information about that returned object.

In my case. this is my output with var_dump


If you want to see more detailed information. Use symfony var_dumper component.

Here is it's output.