1

I am trying to run a Console command. I created command which ran successfully, but when I tried to connect to database, it shows an error on Console:

[PDOException] could not find driver

I am using this to get record from database

$conn = $this->getContainer()->get('database_connection');
$sql = "SELECT * FROM tablename WHERE id = 1";
$data = $conn->fetchAssoc($sql);
$output->writeln($data['field_name']);

I am using PostgreSQL with Doctrine DBAL

I am using this command in Windows command line to run the Console command in Symfony:

> php app/console demo:actionfordb

Please guide me what and where I am doing wrong?

Chris Travers
  • 25,424
  • 6
  • 65
  • 182
Haseeb Jehanzeb
  • 319
  • 5
  • 9
  • 2
    Check your php.ini used by your php client (not the one used by apache or IIS) to be sure that pdo_pgsql extension is loaded – Picoss Oct 02 '13 at 12:52
  • Yes, that's what was the issue. I had 2 versions of PHP stored in Environment variables. The one running was causing the issue. Thank you! – Haseeb Jehanzeb Oct 04 '13 at 14:26

0 Answers0