<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Automatically choose database connections in CakePHP</title>
	<atom:link href="http://edwardawebb.com/programming/php-programming/cakephp/automatically-choose-database-connections-cakephp/feed/" rel="self" type="application/rss+xml" />
	<link>http://edwardawebb.com/programming/php-programming/cakephp/automatically-choose-database-connections-cakephp</link>
	<description>get all his digital goodness 24/7</description>
	<lastBuildDate>Mon, 08 Mar 2010 15:08:48 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=abc</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
	<item>
		<title>By: ZEE4 &#187; Blog Archive &#187; CakePHP database config quick-tip</title>
		<link>http://edwardawebb.com/programming/php-programming/cakephp/automatically-choose-database-connections-cakephp/comment-page-1/#comment-1278</link>
		<dc:creator>ZEE4 &#187; Blog Archive &#187; CakePHP database config quick-tip</dc:creator>
		<pubDate>Sun, 10 Jan 2010 17:06:40 +0000</pubDate>
		<guid isPermaLink="false">http://edwardawebb.com/?p=28#comment-1278</guid>
		<description>[...] If you haven&#8217;t, check out Edward A. Webb&#8217;s original post from 1998 [...]</description>
		<content:encoded><![CDATA[<p>[...] If you haven&#8217;t, check out Edward A. Webb&#8217;s original post from 1998 [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sharon</title>
		<link>http://edwardawebb.com/programming/php-programming/cakephp/automatically-choose-database-connections-cakephp/comment-page-1/#comment-577</link>
		<dc:creator>Sharon</dc:creator>
		<pubDate>Tue, 07 Apr 2009 15:14:42 +0000</pubDate>
		<guid isPermaLink="false">http://edwardawebb.com/?p=28#comment-577</guid>
		<description>This was very helpful, thanks!  Solved a problem for me!</description>
		<content:encoded><![CDATA[<p>This was very helpful, thanks!  Solved a problem for me!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex</title>
		<link>http://edwardawebb.com/programming/php-programming/cakephp/automatically-choose-database-connections-cakephp/comment-page-1/#comment-136</link>
		<dc:creator>Alex</dc:creator>
		<pubDate>Tue, 03 Feb 2009 20:54:05 +0000</pubDate>
		<guid isPermaLink="false">http://edwardawebb.com/?p=28#comment-136</guid>
		<description>Small point, how about reducing it further?

function __construct () {
  // Set default DB 
  $this-&gt;default = $_SERVER[&#039;SERVER_NAME&#039;] ==&#039;digbiz.example.com&#039;?$this-&gt;prod:$this-&gt;dev;
}</description>
		<content:encoded><![CDATA[<p>Small point, how about reducing it further?</p>
<p>function __construct () {<br />
  // Set default DB<br />
  $this-&gt;default = $_SERVER['SERVER_NAME'] ==&#8217;digbiz.example.com&#8217;?$this-&gt;prod:$this-&gt;dev;<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Raphael Spindell</title>
		<link>http://edwardawebb.com/programming/php-programming/cakephp/automatically-choose-database-connections-cakephp/comment-page-1/#comment-69</link>
		<dc:creator>Raphael Spindell</dc:creator>
		<pubDate>Mon, 03 Nov 2008 00:31:21 +0000</pubDate>
		<guid isPermaLink="false">http://edwardawebb.com/?p=28#comment-69</guid>
		<description>Why not streamline all this if/else and just use the default: case

//check to see if server name is set (thanks Frank)
		switch($_SERVER[&#039;SERVER_NAME&#039;]){
				case &#039;digbiz.localhost&#039;:
					$this-&gt;default = $this-&gt;dev;
					break;
				case &#039;digbiz.example.com&#039;:
					$this-&gt;default = $this-&gt;prod;
					break;
        default:
    // we are likely baking, use our local db
	        $this-&gt;default = $this-&gt;dev;
}</description>
		<content:encoded><![CDATA[<p>Why not streamline all this if/else and just use the default: case</p>
<p>//check to see if server name is set (thanks Frank)<br />
		switch($_SERVER['SERVER_NAME']){<br />
				case &#8216;digbiz.localhost&#8217;:<br />
					$this-&gt;default = $this-&gt;dev;<br />
					break;<br />
				case &#8216;digbiz.example.com&#8217;:<br />
					$this-&gt;default = $this-&gt;prod;<br />
					break;<br />
        default:<br />
    // we are likely baking, use our local db<br />
	        $this-&gt;default = $this-&gt;dev;<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eddie</title>
		<link>http://edwardawebb.com/programming/php-programming/cakephp/automatically-choose-database-connections-cakephp/comment-page-1/#comment-25</link>
		<dc:creator>Eddie</dc:creator>
		<pubDate>Sat, 23 Aug 2008 20:08:35 +0000</pubDate>
		<guid isPermaLink="false">http://edwardawebb.com/?p=28#comment-25</guid>
		<description>@Frank

Thanks Frank, that is a beautiful tip.

@ Others..
because baking is running as a script at the console, it does not have server values set.  Thus you first check to see if they do not exist(meaning its a local bake), otherwise you may continue by checking names to distinguish development, performance and production servers.</description>
		<content:encoded><![CDATA[<p>@Frank</p>
<p>Thanks Frank, that is a beautiful tip.</p>
<p>@ Others..<br />
because baking is running as a script at the console, it does not have server values set.  Thus you first check to see if they do not exist(meaning its a local bake), otherwise you may continue by checking names to distinguish development, performance and production servers.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Frank</title>
		<link>http://edwardawebb.com/programming/php-programming/cakephp/automatically-choose-database-connections-cakephp/comment-page-1/#comment-14</link>
		<dc:creator>Frank</dc:creator>
		<pubDate>Mon, 18 Aug 2008 17:22:51 +0000</pubDate>
		<guid isPermaLink="false">http://edwardawebb.com/?p=28#comment-14</guid>
		<description>@Nick I was also having trouble baking, check if $_SERVER isset to sort it out:

if (isset($_SERVER[&#039;SERVER_NAME&#039;]) &amp;&amp; !strstr($_SERVER[&#039;SERVER_NAME&#039;], &#039;localhost&#039;)) { etc...</description>
		<content:encoded><![CDATA[<p>@Nick I was also having trouble baking, check if $_SERVER isset to sort it out:</p>
<p>if (isset($_SERVER['SERVER_NAME']) &amp;&amp; !strstr($_SERVER['SERVER_NAME'], &#8216;localhost&#8217;)) { etc&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: admin</title>
		<link>http://edwardawebb.com/programming/php-programming/cakephp/automatically-choose-database-connections-cakephp/comment-page-1/#comment-7</link>
		<dc:creator>admin</dc:creator>
		<pubDate>Wed, 23 Jul 2008 04:10:24 +0000</pubDate>
		<guid isPermaLink="false">http://edwardawebb.com/?p=28#comment-7</guid>
		<description>@Mandy
I don&#039;t that is something you would want to do in this class, since it comes before connections are made. But, cake has custom error pages based on missing tables.
&lt;b&gt;If you want something more advance you should visit Felix Geisendörfer&#039;s article &lt;a href=&quot;http://debuggable.com/posts/handling-database-connection-errors-in-cakephp:480f4dd5-9570-421a-a04d-43cdcbdd56cb&quot; title=&quot;Handling DB errors in CakePHP&quot; rel=&quot;nofollow&quot;&gt;Handling database connection errors in CakePHP&lt;/a&gt;&lt;/b&gt;</description>
		<content:encoded><![CDATA[<p>@Mandy<br />
I don&#8217;t that is something you would want to do in this class, since it comes before connections are made. But, cake has custom error pages based on missing tables.<br />
<b>If you want something more advance you should visit Felix Geisendörfer&#8217;s article <a href="http://debuggable.com/posts/handling-database-connection-errors-in-cakephp:480f4dd5-9570-421a-a04d-43cdcbdd56cb" title="Handling DB errors in CakePHP" rel="nofollow">Handling database connection errors in CakePHP</a></b></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mandy</title>
		<link>http://edwardawebb.com/programming/php-programming/cakephp/automatically-choose-database-connections-cakephp/comment-page-1/#comment-6</link>
		<dc:creator>Mandy</dc:creator>
		<pubDate>Wed, 23 Jul 2008 03:15:35 +0000</pubDate>
		<guid isPermaLink="false">http://edwardawebb.com/?p=28#comment-6</guid>
		<description>how about checking for db connection as well at this time and if db is down (ie site is down) redirecting to an error page?</description>
		<content:encoded><![CDATA[<p>how about checking for db connection as well at this time and if db is down (ie site is down) redirecting to an error page?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nick</title>
		<link>http://edwardawebb.com/programming/php-programming/cakephp/automatically-choose-database-connections-cakephp/comment-page-1/#comment-2</link>
		<dc:creator>Nick</dc:creator>
		<pubDate>Fri, 11 Jul 2008 17:03:22 +0000</pubDate>
		<guid isPermaLink="false">http://edwardawebb.com/?p=28#comment-2</guid>
		<description>So sweet! I am having issues with baking though, any thoughts?</description>
		<content:encoded><![CDATA[<p>So sweet! I am having issues with baking though, any thoughts?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
