<?xml version="1.0"?>
<rss version="2.0">
  <channel>
    <title>PHPDeveloper.org</title>
    <link>http://www.phpdeveloper.org</link>
    <description>Up-to-the Minute PHP News, views and community</description>
    <language>en-us</language>
    <pubDate>Fri, 24 May 2013 20:33:38 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Ilia Alshanetsky's Blog: Database connection fallback with PDO]]></title>
      <guid>http://www.phpdeveloper.org/news/18040</guid>
      <link>http://www.phpdeveloper.org/news/18040</link>
      <description><![CDATA[<p>
<i>Ilia Alshanetsky</i> has a new post to his blog sharing a <a href="http://ilia.ws/archives/249-Database-connection-fallback-with-PDO.html">method for fallback with PDO</a> when your database connection fails.
</p>
<blockquote>
For our database connections we PDO at work and we've extended the class with PHP to offer some other convenience functionality and wrappers. One of the things I wanted to do recently is allow the constructor of the PDO class to fail-over to our backup database connection pool in the event the primary was not available.
</blockquote>
<p>
He wanted his code to catch an exception if the object was created with a failed server host and to connect to the backup instead. PDO doesn't cooperate with this method and just destroys the object when there's a failure. His work around is in <a href="http://ilia.ws/patch/pdo.txt">this patch</a> to the PDO support in PHP to provide a new constant, PDO:: ATTR_KEEP_CLASS_CONN_FAILURE, that tells the script wether or not to destroy the PDO object when there's a problem.
</p>]]></description>
      <pubDate>Mon, 04 Jun 2012 09:50:26 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Evolt.org: Failover Database Connection with PHP + mySQL]]></title>
      <guid>http://www.phpdeveloper.org/news/7883</guid>
      <link>http://www.phpdeveloper.org/news/7883</link>
      <description><![CDATA[<p>
Evolt.org has a <a href="http://evolt.org/failover-database-connection-with-php-mysql">recently posted tutorial</a> that talks about creating a simple failover database connection for your PHP and MySQL application.
</p>
<blockquote>
Imagine, you're connecting to a mySQL database with PHP, but hell, you want a bit more robustness. So why would you want just one database? You'd use a failover right? So if the first database is down or just doesn't connect, it can connect to the next one. Here's how to do that (I'm assuming you're already replicating between databases so that they're roughly in sync). Here's how you do it.
</blockquote>
<p>
<a href="http://evolt.org/failover-database-connection-with-php-mysql">The tutorial</a> walks you through the creation of a simple MySQL connection, but with two sets of credentials. The script tests the connection to the first database and, if it doesn't get a valid resource back, it falls back on the secondary. Of course, keeping the data in sync is your job.
</p>]]></description>
      <pubDate>Mon, 21 May 2007 12:04:00 -0500</pubDate>
    </item>
  </channel>
</rss>
