<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jedidiah's Blog &#187; CodeIgniter</title>
	<atom:link href="http://jedidiahreeser.com/blog/category/codeigniter/feed/" rel="self" type="application/rss+xml" />
	<link>http://jedidiahreeser.com/blog</link>
	<description>Technology Information Exchange</description>
	<lastBuildDate>Wed, 22 Jul 2009 02:24:13 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Accessing Multiple Databases in CodeIgniter</title>
		<link>http://jedidiahreeser.com/blog/2009/07/accessing-multiple-databases-codeigniter/</link>
		<comments>http://jedidiahreeser.com/blog/2009/07/accessing-multiple-databases-codeigniter/#comments</comments>
		<pubDate>Tue, 21 Jul 2009 00:23:30 +0000</pubDate>
		<dc:creator>Jedidiah</dc:creator>
				<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[controller]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[jedidiah reeser]]></category>
		<category><![CDATA[krystal reeser]]></category>
		<category><![CDATA[model]]></category>
		<category><![CDATA[multiple database]]></category>
		<category><![CDATA[view]]></category>

		<guid isPermaLink="false">http://jedidiahreeser.com/blog/?p=62</guid>
		<description><![CDATA[This video tutorial will show you how to connect multiple databases with CodeIgniter. Tutorial by Jedidiah Reeser and Krystal Reeser of JedidiahMedia.com.]]></description>
			<content:encoded><![CDATA[<p><object width="800" height="600" data="http://jedidiahreeser.com/blog/wp-content/uploads/2009/07/multipledatabasesincodeigniter.swf" type="application/x-shockwave-flash"><param name="quality" value="high" /><param name="scale" value="noborder" /><param name="wmode" value="transparent" /><param name="src" value="http://jedidiahreeser.com/blog/wp-content/uploads/2009/07/multipledatabasesincodeigniter.swf" /></object><br />
<h3>Multiple Databases In Codeigniter</h3>
<p>Here is the general transcript from the video, however the video includes a lot more:</p>
<p>
Hello, this is Jedidiah Reeser from <a href="http://www.jedidiahmedia.com">JedidiahMedia.com</a>. Today, I&#8217;m going to show you how to connect to multiple databases in CodeIgniter.</p>
<p>
<strong>Step 1</strong><br /> I am going to add the secondary database details in the config folder. I will open database.php in the config folder which is found in the application folder. I will copy and paste the database settings and change default to second_db.</p>
<p>
<strong>Step 2</strong> <br />Next, I will go to the controller and add the code to load the model.</p>
<pre class="brush: php;">
 $this-&gt;load-&gt;model('example','', TRUE);
</pre>
<p><strong>Step 3</strong> <br />Then I will go to the model and make it connect to the second database. To do this, I will add a private variable in the class. In the constructor function I will load the second database. I will create a function  to run a query using the second database.</p>
<pre class="brush: php; highlight: [3,8,14];">

class Example extends Model
{
  private $second_db;

  function Example()
  {
      parent::Model();
      $this-&gt;second_db = $this-&gt;load-&gt;database('second_db', TRUE);
  }

function get_latest()
{
    $info = '';
    $query = $this-&gt;second_db-&gt;query('SELECT * FROM wp_posts limit 3');

    if ($query-&gt;num_rows() &gt; 0 ){
      $info .= '&lt;ul&gt;';
       foreach ($query-&gt;result() as $row)
        {
            $info .= '
            &lt;li&gt;
              &lt;h3&gt;'.$row-&gt;post_title.'&lt;/h3&gt;
            &lt;br /&gt;
            &lt;div&gt;'.$row-&gt;post_excerpt.'&lt;/div&gt;
           &lt;/li&gt;
            ';
        }
        $info .= '&lt;/ul&gt;';
    }

    return $info;

    }
}
</pre>
<p><strong>Step 4</strong> <br />After that I will open the controller and send the information to the view.</p>
<pre class="brush: php; highlight: [7];">
 $this-&gt;load-&gt;model('example','', TRUE);

 $data['posts'] = '
     &lt;div id=&quot;blogposts&quot;&gt;
    &lt;h2&gt;Recent Posts&lt;/h2&gt;
    ';
    $data['posts'] .= $this-&gt;example-&gt;get_latest();

    $data['posts'] .= '&lt;/div&gt;';

    $this-&gt;load-&gt;view('welcome_message', $data);
</pre>
<p><strong>Step 5</strong> <br />Then, I will go to the view and display the information.</p>
<pre class="brush: php;">
    &lt;?=$posts;?&gt;
</pre>
<p><strong>Thanks for watching!</strong> I hope that you have found this video tutorial helpful. For more tips or information, please visit my sites at: <a href="http://jedidiahreeser.com/">jedidiahreeser.com</a> and <a href="http://jedidiahmedia.com/">jedidiahmedia.com</a>. And a special thanks to <a href="http://krystalreeser.com/">Krystal Reeser</a> for helping me create this video.</p>
<p class="buymebeer"><form action="https://www.paypal.com/cgi-bin/webscr" target="paypal" method="post"><input type="hidden" name="cmd" value="_xclick" /><input type="hidden" name="business" value="jedidiahreeser@gmail.com" /><input type="hidden" name="return" value="" /><input type="hidden" name="item_name" value="Buy Me a Coffee for Accessing Multiple Databases in CodeIgniter" /><input type="hidden" name="currency_code" value="USD" /><input type="hidden" name="amount" value="" /><input type="image" src="http://jedidiahreeser.com/blog/wp-content/plugins/buy-me-beer/icon_cafe.gif" align="left" alt="" title="" hspace="3" /></form><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&amp;business=jedidiahreeser@gmail.com&amp;currency_code=USD&amp;amount=&amp;return=&amp;item_name=Buy+Me+a+Coffee+for+Accessing+Multiple+Databases+in+CodeIgniter" target="paypal">Buy Me a Coffee</a></p><div class="sexy-bookmarks"><ul class="socials"><li class="sexy-scriptstyle"><a href="http://scriptandstyle.com/submit?url=http://jedidiahreeser.com/blog/2009/07/accessing-multiple-databases-codeigniter/&amp;title=Accessing+Multiple+Databases+in+CodeIgniter" rel="external nofollow" title="Submit this to Script &amp; Style">Submit this to Script &amp; Style</a></li><li class="sexy-blinklist"><a href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=http://jedidiahreeser.com/blog/2009/07/accessing-multiple-databases-codeigniter/&amp;Title=Accessing+Multiple+Databases+in+CodeIgniter" rel="external nofollow" title="Share this on Blinklist">Share this on Blinklist</a></li><li class="sexy-delicious"><a href="http://del.icio.us/post?url=http://jedidiahreeser.com/blog/2009/07/accessing-multiple-databases-codeigniter/&amp;title=Accessing+Multiple+Databases+in+CodeIgniter" rel="external nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a></li><li class="sexy-digg"><a href="http://digg.com/submit?phase=2&amp;url=http://jedidiahreeser.com/blog/2009/07/accessing-multiple-databases-codeigniter/&amp;title=Accessing+Multiple+Databases+in+CodeIgniter" rel="external nofollow" title="Digg this!">Digg this!</a></li><li class="sexy-diigo"><a href="http://www.diigo.com/post?url=http://jedidiahreeser.com/blog/2009/07/accessing-multiple-databases-codeigniter/&amp;title=Accessing+Multiple+Databases+in+CodeIgniter&amp;desc=Multiple%20Databases%20In%20Codeigniter%0D%0A%0D%0AHere%20is%20the%20general%20transcript%20from%20the%20video%2C%20however%20the%20video%20includes%20a%20lot%20more%3A%0D%0A%0D%0A%0D%0AHello%2C%20this%20is%20Jedidiah%20Reeser%20from%20JedidiahMedia.com.%20Today%2C%20I%27m%20going%20to%20show%20you%20how%20to%20connect%20to%20multiple%20databases%20in%20CodeIgniter.%0D%0A%0D%0A%0D%0AStep%201%20I%20am%20going%20to%20add%20the%20s" rel="external nofollow" title="Post this on Diigo">Post this on Diigo</a></li><li class="sexy-reddit"><a href="http://reddit.com/submit?url=http://jedidiahreeser.com/blog/2009/07/accessing-multiple-databases-codeigniter/&amp;title=Accessing+Multiple+Databases+in+CodeIgniter" rel="external nofollow" title="Share this on Reddit">Share this on Reddit</a></li><li class="sexy-yahoobuzz"><a href="http://buzz.yahoo.com/submit/?submitUrl=http://jedidiahreeser.com/blog/2009/07/accessing-multiple-databases-codeigniter/&amp;submitHeadline=Accessing+Multiple+Databases+in+CodeIgniter&amp;submitSummary=Multiple%20Databases%20In%20Codeigniter%0D%0A%0D%0AHere%20is%20the%20general%20transcript%20from%20the%20video%2C%20however%20the%20video%20includes%20a%20lot%20more%3A%0D%0A%0D%0A%0D%0AHello%2C%20this%20is%20Jedidiah%20Reeser%20from%20JedidiahMedia.com.%20Today%2C%20I%27m%20going%20to%20show%20you%20how%20to%20connect%20to%20multiple%20databases%20in%20CodeIgniter.%0D%0A%0D%0A%0D%0AStep%201%20I%20am%20going%20to%20add%20the%20s&amp;submitCategory=science&amp;submitAssetType=text" rel="external nofollow" title="Buzz up!">Buzz up!</a></li><li class="sexy-stumbleupon"><a href="http://www.stumbleupon.com/submit?url=http://jedidiahreeser.com/blog/2009/07/accessing-multiple-databases-codeigniter/&amp;title=Accessing+Multiple+Databases+in+CodeIgniter" rel="external nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a></li><li class="sexy-technorati"><a href="http://technorati.com/faves?add=http://jedidiahreeser.com/blog/2009/07/accessing-multiple-databases-codeigniter/" rel="external nofollow" title="Share this on Technorati">Share this on Technorati</a></li><li class="sexy-mixx"><a href="http://www.mixx.com/submit?page_url=http://jedidiahreeser.com/blog/2009/07/accessing-multiple-databases-codeigniter/&amp;title=Accessing+Multiple+Databases+in+CodeIgniter" rel="external nofollow" title="Share this on Mixx">Share this on Mixx</a></li><li class="sexy-myspace"><a href="http://www.myspace.com/Modules/PostTo/Pages/?u=http://jedidiahreeser.com/blog/2009/07/accessing-multiple-databases-codeigniter/&amp;t=Accessing+Multiple+Databases+in+CodeIgniter" rel="external nofollow" title="Post this to MySpace">Post this to MySpace</a></li><li class="sexy-designfloat"><a href="http://www.designfloat.com/submit.php?url=http://jedidiahreeser.com/blog/2009/07/accessing-multiple-databases-codeigniter/&amp;title=Accessing+Multiple+Databases+in+CodeIgniter" rel="external nofollow" title="Submit this to DesignFloat">Submit this to DesignFloat</a></li><li class="sexy-facebook"><a href="http://www.facebook.com/share.php?u=http://jedidiahreeser.com/blog/2009/07/accessing-multiple-databases-codeigniter/&amp;t=Accessing+Multiple+Databases+in+CodeIgniter" rel="external nofollow" title="Share this on Facebook">Share this on Facebook</a></li><li class="sexy-twitter"><a href="http://www.twitter.com/home?status=RT+@jedidiahr:+Accessing+Multiple+Databases+in+CodeIgniter+-+http://tinyurl.com/mznzv9" rel="external nofollow" title="Tweet This!">Tweet This!</a></li><li class="sexy-mail"><a href="mailto:?&amp;subject=Accessing%20Multiple%20Databases%20in%20CodeIgniter&amp;body=Multiple%20Databases%20In%20Codeigniter%0D%0A%0D%0AHere%20is%20the%20general%20transcript%20from%20the%20video%2C%20however%20the%20video%20includes%20a%20lot%20more%3A%0D%0A%0D%0A%0D%0AHello%2C%20this%20is%20Jedidiah%20Reeser%20from%20JedidiahMedia.com.%20Today%2C%20I%27m%20going%20to%20show%20you%20how%20to%20connect%20to%20multiple%20databases%20in%20CodeIgniter.%0D%0A%0D%0A%0D%0AStep%201%20I%20am%20going%20to%20add%20the%20s - http://jedidiahreeser.com/blog/2009/07/accessing-multiple-databases-codeigniter/" rel="external nofollow" title="Email this to a friend?">Email this to a friend?</a></li><li class="sexy-comfeed"><a href="http://jedidiahreeser.com/blog/2009/07/accessing-multiple-databases-codeigniter/feed" rel="external nofollow" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a></li><li class="sexy-linkedin"><a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://jedidiahreeser.com/blog/2009/07/accessing-multiple-databases-codeigniter/&amp;title=Accessing+Multiple+Databases+in+CodeIgniter&amp;summary=Multiple%20Databases%20In%20Codeigniter%0D%0A%0D%0AHere%20is%20the%20general%20transcript%20from%20the%20video%2C%20however%20the%20video%20includes%20a%20lot%20more%3A%0D%0A%0D%0A%0D%0AHello%2C%20this%20is%20Jedidiah%20Reeser%20from%20JedidiahMedia.com.%20Today%2C%20I%27m%20going%20to%20show%20you%20how%20to%20connect%20to%20multiple%20databases%20in%20CodeIgniter.%0D%0A%0D%0A%0D%0AStep%201%20I%20am%20going%20to%20add%20the%20s&amp;source=Jedidiah's Blog" rel="external nofollow" title="Share this on Linkedin">Share this on Linkedin</a></li><li class="sexy-newsvine"><a href="http://www.newsvine.com/_tools/seed&amp;save?u=http://jedidiahreeser.com/blog/2009/07/accessing-multiple-databases-codeigniter/&amp;h=Accessing+Multiple+Databases+in+CodeIgniter" rel="external nofollow" title="Seed this on Newsvine">Seed this on Newsvine</a></li><li class="sexy-devmarks"><a href="http://devmarks.com/index.php?posttext=Multiple%20Databases%20In%20Codeigniter%0D%0A%0D%0AHere%20is%20the%20general%20transcript%20from%20the%20video%2C%20however%20the%20video%20includes%20a%20lot%20more%3A%0D%0A%0D%0A%0D%0AHello%2C%20this%20is%20Jedidiah%20Reeser%20from%20JedidiahMedia.com.%20Today%2C%20I%27m%20going%20to%20show%20you%20how%20to%20connect%20to%20multiple%20databases%20in%20CodeIgniter.%0D%0A%0D%0A%0D%0AStep%201%20I%20am%20going%20to%20add%20the%20s&amp;posturl=http://jedidiahreeser.com/blog/2009/07/accessing-multiple-databases-codeigniter/&amp;posttitle=Accessing+Multiple+Databases+in+CodeIgniter" rel="external nofollow" title="Share this on Devmarks">Share this on Devmarks</a></li><li class="sexy-google"><a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://jedidiahreeser.com/blog/2009/07/accessing-multiple-databases-codeigniter/title=Accessing+Multiple+Databases+in+CodeIgniter" rel="external nofollow" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a></li><li class="sexy-misterwong"><a href="http://www.mister-wong.com/addurl/?bm_url=http://jedidiahreeser.com/blog/2009/07/accessing-multiple-databases-codeigniter/&amp;bm_description=Accessing+Multiple+Databases+in+CodeIgniter&amp;plugin=sexybookmarks" rel="external nofollow" title="Add this to Mister Wong">Add this to Mister Wong</a></li><li class="sexy-izeby"><a href="http://izeby.com/add_story.php?story_url=http://jedidiahreeser.com/blog/2009/07/accessing-multiple-databases-codeigniter/" rel="external nofollow" title="Add this to Izeby">Add this to Izeby</a></li><li class="sexy-tumblr"><a href="http://www.tumblr.com/share?v=3&amp;u=http://jedidiahreeser.com/blog/2009/07/accessing-multiple-databases-codeigniter/&amp;t=Accessing+Multiple+Databases+in+CodeIgniter&amp;s=" rel="external nofollow" title="Share this on Tumblr">Share this on Tumblr</a></li><li class="sexy-tipd"><a href="http://tipd.com/submit.php?url=http://jedidiahreeser.com/blog/2009/07/accessing-multiple-databases-codeigniter/" rel="external nofollow" title="Share this on Tipd">Share this on Tipd</a></li><li class="sexy-pfbuzz"><a href="http://pfbuzz.com/submit?url=http://jedidiahreeser.com/blog/2009/07/accessing-multiple-databases-codeigniter/&amp;title=Accessing+Multiple+Databases+in+CodeIgniter" rel="external nofollow" title="Share this on PFBuzz">Share this on PFBuzz</a></li></ul><div style="clear:both;"></div></div>]]></content:encoded>
			<wfw:commentRss>http://jedidiahreeser.com/blog/2009/07/accessing-multiple-databases-codeigniter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
