<p>I've been using PHP &amp; MySQL for ages and am about to start using PostgreSQL instead.</p>

<p>What's the preferred method?  </p>

<p>Is it via the PDO objects or is there something better?</p>

[{'answer_id': 10542, 'author': 'pix0r', 'author_id': 72, 'author_profile': 'https://Stackoverflow.com/users/72', 'pm_score': 4, 'selected': True, 'text': '<p>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+.</p>\n\n<p>There are many other database abstraction layers that support PostgreSQL that are compatible with older versions of PHP; I\'d recommend <a href="http://adodb.sourceforge.net/" rel="noreferrer">ADODB</a>.</p>\n\n<p>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!</p>\n'}, {'answer_id': 10544, 'author': 'MattBelanger', 'author_id': 655, 'author_profile': 'https://Stackoverflow.com/users/655', 'pm_score': 1, 'selected': False, 'text': '<p>I,  personally, use PDO for all my database work when I have the choice.  Prepared statements make my life easy, and it is seamless between database systems - handy if you have to work with one you\'re not used to.</p>\n\n<p>If you want to roll your own abstraction, or go with the procedural model, here\'s the Postgre functions: <a href="http://ca.php.net/manual/en/ref.pgsql.php" rel="nofollow noreferrer">http://ca.php.net/manual/en/ref.pgsql.php</a></p>\n'}, {'answer_id': 10675, 'author': 'Eldila', 'author_id': 889, 'author_profile': 'https://Stackoverflow.com/users/889', 'pm_score': 0, 'selected': False, 'text': '<p>I would also suggest creating an inherited PDO class or a wrapper class if you decide not to use PDO. This would provide you with a lot more flexibility in the future. ie. Calculating query execution time.</p>\n'}, {'answer_id': 10689, 'author': 'grom', 'author_id': 486, 'author_profile': 'https://Stackoverflow.com/users/486', 'pm_score': 2, 'selected': False, 'text': "<p>Using Zend Db:</p>\n\n<pre><code>require_once 'Zend/Db.php';\n$DB_ADAPTER = 'Pdo_Pgsql';\n$DB_CONFIG = array(\n    'username' =&gt; 'app_db_user',\n    'password' =&gt; 'xxxxxxxxx',\n    'host'     =&gt; 'localhost',\n    'port'     =&gt; 5432,\n    'dbname'   =&gt; 'mydb'\n);\n$db = Zend_Db::factory($DB_ADAPTER, $DB_CONFIG);\n</code></pre>\n"}, {'answer_id': 10700, 'author': 'Grey Panther', 'author_id': 1265, 'author_profile': 'https://Stackoverflow.com/users/1265', 'pm_score': 0, 'selected': False, 'text': '<p>Depending on the scale of your application, you might wish to consider the number of connections going to the backend. The consensus seem to be that PHP persistent connections and PostgreSQL don\'t work well together, so something like <a href="http://pgpool.projects.postgresql.org/" rel="nofollow noreferrer" title="pgpool-II">pgpool-||</a> should be used as an intermediary.</p>\n'}, {'answer_id': 107169, 'author': 'Andy Lester', 'author_id': 8454, 'author_profile': 'https://Stackoverflow.com/users/8454', 'pm_score': 1, 'selected': False, 'text': '<p>There are also <a href="http://us.php.net/manual/en/book.pgsql.php" rel="nofollow noreferrer">the pg_whatever functions</a>, but don\'t use them. </p>\n\n<p>They use older, unmaintained database drivers.  <a href="http://us.php.net/pdo" rel="nofollow noreferrer">PDO</a> is the way to go.</p>\n'}]
['https://Stackoverflow.com/questions/10532', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/305/']