<?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: Easy Dynamic Database Connection in CakePHP</title>
	<atom:link href="http://labs.iamkoa.net/2007/10/29/easy-dynamic-database-connection-in-cakephp/feed/" rel="self" type="application/rss+xml" />
	<link>http://labs.iamkoa.net/2007/10/29/easy-dynamic-database-connection-in-cakephp/</link>
	<description>I break it. I fix it. You learn.</description>
	<lastBuildDate>Tue, 13 Jul 2010 11:10:57 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: Traian</title>
		<link>http://labs.iamkoa.net/2007/10/29/easy-dynamic-database-connection-in-cakephp/comment-page-1/#comment-306</link>
		<dc:creator>Traian</dc:creator>
		<pubDate>Thu, 22 Jan 2009 21:49:48 +0000</pubDate>
		<guid isPermaLink="false">http://labs.iamkoa.net/2007/10/29/easy-dynamic-database-connection-in-cakephp/#comment-306</guid>
		<description>Thanks a lot, you made my day!</description>
		<content:encoded><![CDATA[<p>Thanks a lot, you made my day!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Samurai</title>
		<link>http://labs.iamkoa.net/2007/10/29/easy-dynamic-database-connection-in-cakephp/comment-page-1/#comment-293</link>
		<dc:creator>Samurai</dc:creator>
		<pubDate>Thu, 11 Dec 2008 23:14:08 +0000</pubDate>
		<guid isPermaLink="false">http://labs.iamkoa.net/2007/10/29/easy-dynamic-database-connection-in-cakephp/#comment-293</guid>
		<description>Thanks from Ukraine for the article!</description>
		<content:encoded><![CDATA[<p>Thanks from Ukraine for the article!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Suryya</title>
		<link>http://labs.iamkoa.net/2007/10/29/easy-dynamic-database-connection-in-cakephp/comment-page-1/#comment-255</link>
		<dc:creator>Suryya</dc:creator>
		<pubDate>Wed, 05 Nov 2008 04:15:30 +0000</pubDate>
		<guid isPermaLink="false">http://labs.iamkoa.net/2007/10/29/easy-dynamic-database-connection-in-cakephp/#comment-255</guid>
		<description>Hey thanx for the help.. nice work. i was searching in the net for some kinda stuff which would help me to modify/create a new database. n u know.  u just did......  : )
 Appreciate  Your Effort !!
Keep Helping..</description>
		<content:encoded><![CDATA[<p>Hey thanx for the help.. nice work. i was searching in the net for some kinda stuff which would help me to modify/create a new database. n u know.  u just did&#8230;&#8230;  : )<br />
 Appreciate  Your Effort !!<br />
Keep Helping..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brett Wilton</title>
		<link>http://labs.iamkoa.net/2007/10/29/easy-dynamic-database-connection-in-cakephp/comment-page-1/#comment-250</link>
		<dc:creator>Brett Wilton</dc:creator>
		<pubDate>Mon, 03 Nov 2008 02:46:43 +0000</pubDate>
		<guid isPermaLink="false">http://labs.iamkoa.net/2007/10/29/easy-dynamic-database-connection-in-cakephp/#comment-250</guid>
		<description>Thanks for the article, been wanting to find a solution to this for a while now.</description>
		<content:encoded><![CDATA[<p>Thanks for the article, been wanting to find a solution to this for a while now.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James Revillini</title>
		<link>http://labs.iamkoa.net/2007/10/29/easy-dynamic-database-connection-in-cakephp/comment-page-1/#comment-243</link>
		<dc:creator>James Revillini</dc:creator>
		<pubDate>Fri, 24 Oct 2008 01:41:49 +0000</pubDate>
		<guid isPermaLink="false">http://labs.iamkoa.net/2007/10/29/easy-dynamic-database-connection-in-cakephp/#comment-243</guid>
		<description>dude - love the code, love the site.  thanks for being so generous.  peace!</description>
		<content:encoded><![CDATA[<p>dude &#8211; love the code, love the site.  thanks for being so generous.  peace!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: demi</title>
		<link>http://labs.iamkoa.net/2007/10/29/easy-dynamic-database-connection-in-cakephp/comment-page-1/#comment-212</link>
		<dc:creator>demi</dc:creator>
		<pubDate>Mon, 18 Aug 2008 09:54:32 +0000</pubDate>
		<guid isPermaLink="false">http://labs.iamkoa.net/2007/10/29/easy-dynamic-database-connection-in-cakephp/#comment-212</guid>
		<description>Hello! I&#039;ve just simplified you conception. I&#039;ve add mapping in the top of the DATABASE_CONFIG:
&lt;pre&gt;&lt;code&gt;
var $map = array(
	&#039;example.localhost&#039;	=&gt;	&#039;local&#039;,
	&#039;dev.example.com&#039;	=&gt;	&#039;dev&#039;,
	&#039;test.example.com&#039;	=&gt;	&#039;test&#039;,
	&#039;example.com&#039;		=&gt;	&#039;live&#039;
);
&lt;/code&gt;&lt;/pre&gt;

And intstead of your constructor write own:
&lt;pre&gt;&lt;code&gt;
function __construct() {
	$this-&gt;default = $this-&gt;{$this-&gt;map[$_SERVER[&#039;SERVER_NAME&#039;]]};
}
&lt;/code&gt;&lt;/pre&gt;
So, it is unneeded to change code in constructor, also for me it&#039;s very usefull to place dev/test servers on subdomains.

Thank you!</description>
		<content:encoded><![CDATA[<p>Hello! I&#8217;ve just simplified you conception. I&#8217;ve add mapping in the top of the DATABASE_CONFIG:</p>
<pre><code>
var $map = array(
	'example.localhost'	=>	'local',
	'dev.example.com'	=>	'dev',
	'test.example.com'	=>	'test',
	'example.com'		=>	'live'
);
</code></pre>
<p>And intstead of your constructor write own:</p>
<pre><code>
function __construct() {
	$this->default = $this->{$this->map[$_SERVER['SERVER_NAME']]};
}
</code></pre>
<p>So, it is unneeded to change code in constructor, also for me it&#8217;s very usefull to place dev/test servers on subdomains.</p>
<p>Thank you!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Barak</title>
		<link>http://labs.iamkoa.net/2007/10/29/easy-dynamic-database-connection-in-cakephp/comment-page-1/#comment-210</link>
		<dc:creator>Barak</dc:creator>
		<pubDate>Wed, 13 Aug 2008 18:27:10 +0000</pubDate>
		<guid isPermaLink="false">http://labs.iamkoa.net/2007/10/29/easy-dynamic-database-connection-in-cakephp/#comment-210</guid>
		<description>Thank you; I was trying to do a require_once() for this purpose but PHP doesn&#039;t like that inside database.php for whatever reason.  Your solution was great... almost perfect.  :)

I made a couple of additions, to support my situation of having the dev server running on a high port, not the standard port 80, and to also accommodate my work style, which includes local and public dev servers in addition to the client&#039;s live/production server.
&lt;pre&gt;&lt;code&gt;
#automatically switch database configuration based on calling server
switch(strtolower($_SERVER[&#039;SERVER_NAME&#039;].&#039;_&#039;.$_SERVER[&#039;SERVER_PORT&#039;]) {
        case &#039;localhost_1080&#039;:
        case &#039;127.0.0.1_1080&#039;:
                $this-&gt;default = $this-&gt;local_cfg;
                break;
        case &#039;publicexample.net_80&#039;:
        case &#039;www.publicexample.net_80&#039;:
                $this-&gt;default = $this-&gt;pub_cfg;
                break;
        case &#039;live.com_80&#039;:
        case &#039;www.live.com_80&#039;:
                $this-&gt;default = $this-&gt;live_cfg;
                break;
        default:
                $this-&gt;default = $this-&gt;local;
}
&lt;/code&gt;&lt;/pre&gt;

BTW, I also use this same type of switch/case in the core.php, so as to set DEBUG to 0 on the live server, 1 on the public dev server, and 2 or 3 on the local dev server.</description>
		<content:encoded><![CDATA[<p>Thank you; I was trying to do a require_once() for this purpose but PHP doesn&#8217;t like that inside database.php for whatever reason.  Your solution was great&#8230; almost perfect.  :)</p>
<p>I made a couple of additions, to support my situation of having the dev server running on a high port, not the standard port 80, and to also accommodate my work style, which includes local and public dev servers in addition to the client&#8217;s live/production server.</p>
<pre><code>
#automatically switch database configuration based on calling server
switch(strtolower($_SERVER['SERVER_NAME'].'_'.$_SERVER['SERVER_PORT']) {
        case 'localhost_1080':
        case '127.0.0.1_1080':
                $this->default = $this->local_cfg;
                break;
        case 'publicexample.net_80':
        case 'www.publicexample.net_80':
                $this->default = $this->pub_cfg;
                break;
        case 'live.com_80':
        case 'www.live.com_80':
                $this->default = $this->live_cfg;
                break;
        default:
                $this->default = $this->local;
}
</code></pre>
<p>BTW, I also use this same type of switch/case in the core.php, so as to set DEBUG to 0 on the live server, 1 on the public dev server, and 2 or 3 on the local dev server.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bornplaydie</title>
		<link>http://labs.iamkoa.net/2007/10/29/easy-dynamic-database-connection-in-cakephp/comment-page-1/#comment-207</link>
		<dc:creator>bornplaydie</dc:creator>
		<pubDate>Mon, 11 Aug 2008 02:59:13 +0000</pubDate>
		<guid isPermaLink="false">http://labs.iamkoa.net/2007/10/29/easy-dynamic-database-connection-in-cakephp/#comment-207</guid>
		<description>Nice! Works like a charm!</description>
		<content:encoded><![CDATA[<p>Nice! Works like a charm!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Koa</title>
		<link>http://labs.iamkoa.net/2007/10/29/easy-dynamic-database-connection-in-cakephp/comment-page-1/#comment-163</link>
		<dc:creator>Koa</dc:creator>
		<pubDate>Mon, 09 Jun 2008 06:06:24 +0000</pubDate>
		<guid isPermaLink="false">http://labs.iamkoa.net/2007/10/29/easy-dynamic-database-connection-in-cakephp/#comment-163</guid>
		<description>Marc &amp; Nick,  glad you found this useful. :}</description>
		<content:encoded><![CDATA[<p>Marc &#038; Nick,  glad you found this useful. :}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: nick</title>
		<link>http://labs.iamkoa.net/2007/10/29/easy-dynamic-database-connection-in-cakephp/comment-page-1/#comment-162</link>
		<dc:creator>nick</dc:creator>
		<pubDate>Sun, 08 Jun 2008 22:25:16 +0000</pubDate>
		<guid isPermaLink="false">http://labs.iamkoa.net/2007/10/29/easy-dynamic-database-connection-in-cakephp/#comment-162</guid>
		<description>thank you so much for this code.  i&#039;ve spent days trying to figure out how to do this.  I was able to successfully get the above code working in 30 seconds.</description>
		<content:encoded><![CDATA[<p>thank you so much for this code.  i&#8217;ve spent days trying to figure out how to do this.  I was able to successfully get the above code working in 30 seconds.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
