pdo postgres database

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jimboidaho
Forum Newbie
Posts: 8
Joined: Wed Jul 07, 2010 11:33 am

pdo postgres database

Post 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.
User avatar
Salaria
Forum Commoner
Posts: 34
Joined: Fri Feb 13, 2009 2:50 am
Location: India
Contact:

Re: pdo postgres database

Post 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.
jimboidaho
Forum Newbie
Posts: 8
Joined: Wed Jul 07, 2010 11:33 am

Re: pdo postgres database

Post by jimboidaho »

Hi Salaria,
I tried your example and it still gives me "could not find driver".
jimboidaho
Forum Newbie
Posts: 8
Joined: Wed Jul 07, 2010 11:33 am

Re: pdo postgres database

Post by jimboidaho »

I found the problem (typo). All is well.
Post Reply