<?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>gEt DoWn ToNiGhT &#187; database</title>
	<atom:link href="http://www.getdowntonight.co.uk/tag/database/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.getdowntonight.co.uk</link>
	<description>amusingly digressive progressive discussions</description>
	<lastBuildDate>Mon, 05 Dec 2011 22:41:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Using the database from inside a helper (CodeIgniter)</title>
		<link>http://www.getdowntonight.co.uk/2010/06/using-the-database-from-inside-a-helper-codeigniter/</link>
		<comments>http://www.getdowntonight.co.uk/2010/06/using-the-database-from-inside-a-helper-codeigniter/#comments</comments>
		<pubDate>Thu, 17 Jun 2010 09:06:17 +0000</pubDate>
		<dc:creator>Sam</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[helper]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.getdowntonight.co.uk/?p=468</guid>
		<description><![CDATA[I have some custom functions that I store in a helper in CodeIgniter. Some of those functions need to use the database, and to do so you have to explicitly tell the function to load the Code Igniter framework and database class. Its pretty simple when you know how, but it took quite a while [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright colorbox-468" title="CodeIgniter Logo" src="http://herloct.files.wordpress.com/2009/05/ci_logo_flame.jpg" alt="" width="90" height="98" />I have some custom functions that I store in a helper in CodeIgniter. </p>
<p>Some of those functions need to use the database, and to do so you have to explicitly tell the function to load the Code Igniter framework and database class.</p>
<p>Its pretty simple when you know how, but it took quite a while to work it out.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> get_user_full_name<span style="color: #009900;">&#40;</span><span style="color: #000088;">$userId</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">//the database functions can not be called from within the helper</span>
    <span style="color: #666666; font-style: italic;">//so we have to explicitly load the functions we need in to an object</span>
    <span style="color: #666666; font-style: italic;">//that I will call ci. then we use that to access the regular stuff.</span>
    <span style="color: #000088;">$ci</span><span style="color: #339933;">=&amp;</span> get_instance<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$ci</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">database</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">//select the required fields from the database</span>
    <span style="color: #000088;">$ci</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">select</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'firstName, lastName'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">//tell the db class the criteria</span>
    <span style="color: #000088;">$ci</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">where</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'userId'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$userId</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">//supply the table name and get the data</span>
    <span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$ci</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'user'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">//ensure that there is something in the variable - in case of no match</span>
    <span style="color: #000088;">$fullName</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">result</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">//get the full name by concatinating the first and last names</span>
        <span style="color: #000088;">$fullName</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">firstName</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot; &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">lastName</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">endforeach</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// return the full name;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$fullName</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.getdowntonight.co.uk/2010/06/using-the-database-from-inside-a-helper-codeigniter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Loading JSON data &#8211; the EASY way!</title>
		<link>http://www.getdowntonight.co.uk/2009/11/loading-json-data-the-easy-way/</link>
		<comments>http://www.getdowntonight.co.uk/2009/11/loading-json-data-the-easy-way/#comments</comments>
		<pubDate>Wed, 18 Nov 2009 12:22:04 +0000</pubDate>
		<dc:creator>Sam</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[web design]]></category>

		<guid isPermaLink="false">http://www.getdowntonight.co.uk/?p=398</guid>
		<description><![CDATA[A few weeks ago I wrote a blog post about using jQuery and JSON to automatically load data from a JSON file in to name-matched controls on an HTML page. It is only now that I realise quite how powerful this is! The great thing about it is that you do not have to edit [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-403 colorbox-398" title="json160" src="http://www.getdowntonight.co.uk/wp-content/json160.gif" alt="json160" width="96" height="96" />A few weeks ago I wrote a blog post about using jQuery and JSON to automatically load data from a JSON file in to name-matched controls on an HTML page.</p>
<p><strong>It is only now that I realise quite how powerful this is!</strong></p>
<p>The great thing about it is that you do not have to edit your data-load function if you add a new field to the database. Because the jQuery function loops through all the fields in the JSON data, it will automatically insert the values in to the correct fields, providing those fields are named the same as the html form controls.</p>
<p>Here is the code again for those who dont want to check back.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$.<span style="color: #660066;">getJSON</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;/yourJson.js, function(myJson){
	$.each(myJson.rows, function(i,item) {
		 for (prop in item) {
		 	 $('#' + prop).val(item[prop]);
		 }
	});
});</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.getdowntonight.co.uk/2009/11/loading-json-data-the-easy-way/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Installing MyODBC 3.51 on Windows 7 x64</title>
		<link>http://www.getdowntonight.co.uk/2009/11/installing-myodbc-3-51-on-windows-7-x64/</link>
		<comments>http://www.getdowntonight.co.uk/2009/11/installing-myodbc-3-51-on-windows-7-x64/#comments</comments>
		<pubDate>Mon, 16 Nov 2009 11:11:44 +0000</pubDate>
		<dc:creator>Sam</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[64 bit]]></category>
		<category><![CDATA[connector]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[myodbc]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[windows 7]]></category>

		<guid isPermaLink="false">http://www.getdowntonight.co.uk/?p=393</guid>
		<description><![CDATA[In order to get some of our 32 bit applications working on Windows 7 64 bit edition, we need to provide support for the MySQL 3.51 ODBC connector. This is actually quite simple to do, as long as you know what to look for. The ODBC manager that you are able to access from within [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-394 colorbox-393" title="mysql2" src="http://www.getdowntonight.co.uk/wp-content/mysql2.png" alt="mysql2" width="105" height="105" />In order to get some of our 32 bit applications working on Windows 7 64 bit edition, we need to provide support for the <a href="http://dev.mysql.com/downloads/connector/odbc/3.51.html" target="_blank">MySQL 3.51 ODBC</a> connector.</p>
<p>This is actually quite simple to do, as long as you know what to look for. The ODBC manager that you are able to access from within Windows is not going to work for you, but it turns out that Microsoft provide a 32 bit manager that will.</p>
<p>To use this manager, run the following command:</p>
<p><strong>c:\windows\syswow64\odbcad32.exe</strong></p>
<p>Please note that it is not good enough to just type odbcad32.exe, as there is another file in the path with the same file name (great work MS!). However, once you have opened this application up, it works in the exact same way as if you were running XP.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.getdowntonight.co.uk/2009/11/installing-myodbc-3-51-on-windows-7-x64/feed/</wfw:commentRss>
		<slash:comments>39</slash:comments>
		</item>
	</channel>
</rss>

