Page 1 of 1

pdo postgres database

Posted: Mon Aug 02, 2010 5:49 pm
by jimboidaho
I am using PHP version 5.3.32 and have followed the directions setting up the PDO drivers but I still get an error "could not find driver" when trying to connect. I can connect using pg_connect() so I know the the database is working correctly. Here is my code.

Code: Select all

$const = "pqsql:host=127.0.0.1 ; dbname=cornmaze ; user=James ; password=aaqdsz1";
try 
{
	$test = new pdo($const);
}
catch (Exception $e)
{
	echo "Caught Message: " . $e->getMessage();
}
I looked at phpinfo() and I see the PDO, pdo_pgsql, and pgsql drivers. I have the following extensions set in my php.ini file and I have confirmed that I am using the correct ini file.
extension=php_pdo.dll
extension=php_pdo_pgsql.dll

Thanks for your help.

Re: pdo postgres database

Posted: Tue Aug 03, 2010 5:47 am
by Salaria
Hi,

Please try following:

Code: Select all

$const = ""pqsql:host=127.0.0.1; dbname=cornmaze";
$user = "James";
$pass = "aaqdsz1";
try{
 $test = PDO($const, $user, $pass);
}
Hope this will work for you.

Re: pdo postgres database

Posted: Tue Aug 03, 2010 8:56 am
by jimboidaho
Hi Salaria,
I tried your example and it still gives me "could not find driver".

Re: pdo postgres database

Posted: Tue Aug 03, 2010 11:22 am
by jimboidaho
I found the problem (typo). All is well.