What’s the preferred way to connect to a postgresql database from PHP?

I’ve been using PHP & MySQL for ages and am about to start using PostgreSQL instead.

What’s the preferred method?

Is it via the PDO objects or is there something better?


PDO objects are the new hotness. I’d recommend that as long as you can ensure that your target platform will always be running PHP 5.2+.

There are many other database abstraction layers that support PostgreSQL that are compatible with older versions of PHP; I’d recommend ADODB.

You should really be using PDO or a different abstraction layer even for your MySQL work; that way you won’t have this problem again!