<?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>spechal.com &#187; PHP</title>
	<atom:link href="http://spechal.com/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://spechal.com</link>
	<description>[spesh-uhl]</description>
	<lastBuildDate>Sat, 24 Dec 2011 03:41:56 +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>Installing php-ffmpeg on CentOS 5.x</title>
		<link>http://spechal.com/2011/07/25/installing-php-ffmpeg-on-centos-5-x/</link>
		<comments>http://spechal.com/2011/07/25/installing-php-ffmpeg-on-centos-5-x/#comments</comments>
		<pubDate>Mon, 25 Jul 2011 16:24:58 +0000</pubDate>
		<dc:creator>Spechal</dc:creator>
				<category><![CDATA[Commands]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[ffmpeg]]></category>
		<category><![CDATA[phpize]]></category>

		<guid isPermaLink="false">http://spechal.com/?p=305</guid>
		<description><![CDATA[This can be a pain due to a bug in the ffpmeg_frame.c file &#8230; here are the commands to get up and going yum -y install ffmpeg ffmpeg-devel wget http://sourceforge.net/projects/ffmpeg-php/files/ffmpeg-php/0.6.0/ffmpeg-php-0.6.0.tbz2/download tar jxvf ffmpeg-php-0.6.0.tbz2 sed -i 's/PIX_FMT_RGBA32/PIX_FMT_RGBA/g' ffmpeg-php-0.6.0/ffmpeg_frame.c cd ffmpeg-php-0.6.0 &#038;&#038; &#8230; <a href="http://spechal.com/2011/07/25/installing-php-ffmpeg-on-centos-5-x/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This can be a pain due to a bug in the ffpmeg_frame.c file &#8230; here are the commands to get up and going</p>
<pre>yum -y install ffmpeg ffmpeg-devel
wget http://sourceforge.net/projects/ffmpeg-php/files/ffmpeg-php/0.6.0/ffmpeg-php-0.6.0.tbz2/download
tar jxvf ffmpeg-php-0.6.0.tbz2
sed -i 's/PIX_FMT_RGBA32/PIX_FMT_RGBA/g' ffmpeg-php-0.6.0/ffmpeg_frame.c
cd ffmpeg-php-0.6.0 &#038;&#038; phpize
./configure &#038;&#038; make &#038;&#038; make install
echo 'extension=ffmpeg.so' > /etc/php.d/ffmpeg.ini &#038;&#038; /etc/init.d/httpd restart
php -v &#038;&#038; php -m | grep ffmpeg
</pre>
<p>In this process you:<br />
use yum to install ffmpeg and the ffmpeg development files<br />
download php-ffmepg from sourceforge and extract it<br />
apply the bug fix to the ffmpeg_frace.c file<br />
change directories to the php-ffmpeg directory and phpize the module<br />
configure, make and install the shared object (extension)<br />
add the extension to the loaded php extensions<br />
restart apache and verify no errors are shown on php startup and that ffmepg is loaded</p>
<p>If all is well, you should see your version of PHP with the copyrights on 3 lines and the last line showing ffmpeg</p>
]]></content:encoded>
			<wfw:commentRss>http://spechal.com/2011/07/25/installing-php-ffmpeg-on-centos-5-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sharpy Lite PHP RAD Framework</title>
		<link>http://spechal.com/2011/03/24/sharpy-lite-php-rad-framework/</link>
		<comments>http://spechal.com/2011/03/24/sharpy-lite-php-rad-framework/#comments</comments>
		<pubDate>Thu, 24 Mar 2011 06:01:02 +0000</pubDate>
		<dc:creator>Spechal</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[PHP RAD Sharpy]]></category>

		<guid isPermaLink="false">http://spechal.com/?p=255</guid>
		<description><![CDATA[So here is part of the Sharpy framework I have been developing with. Once I get things more mature, I will release the whole php rapid application development framework. Download sharpy-lite. Published under the MIT License. Basically just upload the &#8230; <a href="http://spechal.com/2011/03/24/sharpy-lite-php-rad-framework/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>So here is part of the Sharpy framework I have been developing with.  Once I get things more mature, I will release the whole php rapid application development framework.</p>
<p>Download <a href='http://spechal.com/wp-content/uploads/2011/03/sharpy-lite.zip'>sharpy-lite</a>.  Published under the MIT License.</p>
<p>Basically just upload the content to your web server (renaming public_html if needed) and browse to the site.  PHP 5.3.x is required.</p>
<p>I will write up more detailed information upon request, but to get going &#8230;</p>
<p>To create a new module, copy the index module and rename it to whatever you want, without meta characters.  Hyphens are acceptable.</p>
]]></content:encoded>
			<wfw:commentRss>http://spechal.com/2011/03/24/sharpy-lite-php-rad-framework/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery wdCalendar Plugin: Adding double click action</title>
		<link>http://spechal.com/2011/03/09/jquery-wdcalendar-plugin-adding-double-click-action/</link>
		<comments>http://spechal.com/2011/03/09/jquery-wdcalendar-plugin-adding-double-click-action/#comments</comments>
		<pubDate>Wed, 09 Mar 2011 07:28:22 +0000</pubDate>
		<dc:creator>Spechal</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://spechal.com/?p=210</guid>
		<description><![CDATA[You can add a double click by altering the event DIV in jquery.calendar.js i.e. var __SCOLLEVENTTEMP = &#34;&#60;DIV style=\&#34;WIDTH:${width};top:${top};left:${left};\&#34; title=\&#34;${title}\&#34; class=\&#34;chip chip${i} ${drag}\&#34;&#62;&#60;div class=\&#34;dhdV\&#34; style=\&#34;display:none\&#34;&#62;${data}&#60;/div&#62;&#60;DIV style=\&#34;BORDER-BOTTOM-COLOR:${bdcolor}\&#34; class=ct&#62;&#38;nbsp;&#60;/DIV&#62;&#60;DL ondblclick=\&#34;alert(1);\&#34; style=\&#34;BORDER-BOTTOM-COLOR:${bdcolor}; BACKGROUND-COLOR:${bgcolor1}; BORDER-TOP-COLOR: ${bdcolor}; HEIGHT: ${height}px; BORDER-RIGHT-COLOR:${bdcolor}; BORDER-LEFT-COLOR:${bdcolor}\&#34;&#62;&#60;DT style=\&#34;BACKGROUND-COLOR:${bgcolor2}\&#34;&#62;${starttime} - ${endtime} ${icon}&#60;/DT&#62;&#60;DD&#62;&#60;SPAN&#62;${content}&#60;/SPAN&#62;&#60;/DD&#62;&#60;DIV &#8230; <a href="http://spechal.com/2011/03/09/jquery-wdcalendar-plugin-adding-double-click-action/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>You can add a double click by altering the event DIV in jquery.calendar.js</p>
<p>i.e.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">var __SCOLLEVENTTEMP = &quot;&lt;DIV style=\&quot;WIDTH:${width};top:${top};left:${left};\&quot; title=\&quot;${title}\&quot; class=\&quot;chip chip${i} ${drag}\&quot;&gt;&lt;div class=\&quot;dhdV\&quot; style=\&quot;display:none\&quot;&gt;${data}&lt;/div&gt;&lt;DIV style=\&quot;BORDER-BOTTOM-COLOR:${bdcolor}\&quot; class=ct&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DL ondblclick=\&quot;alert(1);\&quot; style=\&quot;BORDER-BOTTOM-COLOR:${bdcolor}; BACKGROUND-COLOR:${bgcolor1}; BORDER-TOP-COLOR: ${bdcolor}; HEIGHT: ${height}px; BORDER-RIGHT-COLOR:${bdcolor}; BORDER-LEFT-COLOR:${bdcolor}\&quot;&gt;&lt;DT style=\&quot;BACKGROUND-COLOR:${bgcolor2}\&quot;&gt;${starttime} - ${endtime} ${icon}&lt;/DT&gt;&lt;DD&gt;&lt;SPAN&gt;${content}&lt;/SPAN&gt;&lt;/DD&gt;&lt;DIV class='resizer' style='display:${redisplay}'&gt;&lt;DIV class=rszr_icon&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DL&gt;&lt;DIV style=\&quot;BORDER-BOTTOM-COLOR:${bdcolor}; BACKGROUND-COLOR:${bgcolor1}; BORDER-TOP-COLOR: ${bdcolor}; BORDER-RIGHT-COLOR: ${bdcolor}; BORDER-LEFT-COLOR:${bdcolor}\&quot; class=cb1&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV style=\&quot;BORDER-BOTTOM-COLOR:${bdcolor}; BORDER-TOP-COLOR:${bdcolor}; BORDER-RIGHT-COLOR:${bdcolor}; BORDER-LEFT-COLOR:${bdcolor}\&quot; class=cb2&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&quot;;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://spechal.com/2011/03/09/jquery-wdcalendar-plugin-adding-double-click-action/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>jQuery wdCalendar Plugin: Expected ajax return</title>
		<link>http://spechal.com/2011/03/09/jquery-wdcalendar-plugin-expected-ajax-return/</link>
		<comments>http://spechal.com/2011/03/09/jquery-wdcalendar-plugin-expected-ajax-return/#comments</comments>
		<pubDate>Wed, 09 Mar 2011 00:56:42 +0000</pubDate>
		<dc:creator>Spechal</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[calendar]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://spechal.com/?p=195</guid>
		<description><![CDATA[This plugin isn&#8217;t documented very well, so I figured I would post the bits and pieces I had issues with and hopefully help someone out. First thing I needed to do was move all the functions into a class and &#8230; <a href="http://spechal.com/2011/03/09/jquery-wdcalendar-plugin-expected-ajax-return/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This plugin isn&#8217;t documented very well, so I figured I would post the bits and pieces I had issues with and hopefully help someone out.</p>
<p>First thing I needed to do was move all the functions into a class and refactor them, but first I wanted the data to still load in the calendar.</p>
<p>The data expected to be returned from the page listing the events is not defined on the <a title="wdCalendar jQuery Calendar Plugin" href="http://www.web-delicious.com/jquery-plugins-demo/wdCalendar/docs/index.htm" target="_blank">wdCalendar</a> project page, so here it is &#8230; in PHP.<br />
<code></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$ret</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'events'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$ret</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'events'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'123456'</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">// cal id</span>
			  <span style="color: #0000ff;">'Title'</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">// event title</span>
			  <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'m/d/Y H:i'</span><span style="color: #339933;">,</span> 
                                 <span style="color: #990000;">strtotime</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'March 8 2011 12:00:00'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">//start</span>
			  <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'m/d/Y H:i'</span><span style="color: #339933;">,</span> 
                                 <span style="color: #990000;">strtotime</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'March 8 2011 16:00:00'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">// end</span>
			  <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">// all day event</span>
			  <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">// more than one day</span>
			  <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">// recurring</span>
			  <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">// color</span>
			  <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">// draggable</span>
			  <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">// editabble</span>
			  <span style="color: #0000ff;">'Address'</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">// address</span>
			  <span style="color: #cc66cc;">0</span> <span style="color: #666666; font-style: italic;">// mark as attending</span>
			<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #990000;">json_encode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ret</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p></code></p>
]]></content:encoded>
			<wfw:commentRss>http://spechal.com/2011/03/09/jquery-wdcalendar-plugin-expected-ajax-return/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Even More Sharpy</title>
		<link>http://spechal.com/2010/12/24/even-more-sharpy/</link>
		<comments>http://spechal.com/2010/12/24/even-more-sharpy/#comments</comments>
		<pubDate>Fri, 24 Dec 2010 11:51:25 +0000</pubDate>
		<dc:creator>Spechal</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Patterns]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://spechal.com/?p=179</guid>
		<description><![CDATA[I am adding a basic Blog app to the base of Sharpy to exemplify how to code using Sharpy &#8230; of course, it is just an example.  I fixed a few bugs in DataMapper and made one to one and &#8230; <a href="http://spechal.com/2010/12/24/even-more-sharpy/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I am adding a basic Blog app to the base of Sharpy to exemplify how to code using Sharpy &#8230; of course, it is just an example.  I fixed a few bugs in DataMapper and made one to one and one to many relationships easier by adding an ID property to DataMapper and including it in the SQL generator bit of DataMapper.  More to come.</p>
]]></content:encoded>
			<wfw:commentRss>http://spechal.com/2010/12/24/even-more-sharpy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>More Sharpy</title>
		<link>http://spechal.com/2010/12/18/more-sharpy/</link>
		<comments>http://spechal.com/2010/12/18/more-sharpy/#comments</comments>
		<pubDate>Sat, 18 Dec 2010 08:54:34 +0000</pubDate>
		<dc:creator>Spechal</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Patterns]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://spechal.com/?p=176</guid>
		<description><![CDATA[Since the last post I&#8217;ve added basic database support for MySQL and PostgreSQL.  In addition is a basic ACL and a DataMapper class to build models from.  I just finished up adding in the ability to execute methods before and &#8230; <a href="http://spechal.com/2010/12/18/more-sharpy/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Since the last post I&#8217;ve added basic database support for MySQL and PostgreSQL.  In addition is a basic ACL and a DataMapper class to build models from.  I just finished up adding in the ability to execute methods before and after any action by using before_filter and after_filter.</p>
<p>Things are moving along.  Hopefully there will be something useful in the near future.</p>
]]></content:encoded>
			<wfw:commentRss>http://spechal.com/2010/12/18/more-sharpy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sharpy</title>
		<link>http://spechal.com/2010/12/16/sharpy/</link>
		<comments>http://spechal.com/2010/12/16/sharpy/#comments</comments>
		<pubDate>Thu, 16 Dec 2010 01:26:51 +0000</pubDate>
		<dc:creator>Spechal</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Patterns]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://spechal.com/?p=174</guid>
		<description><![CDATA[So I decided to start working on a rapid application development (RAD) framework for PHP the other day after a brief stint with Ruby on Rails.  I&#8217;ve decided to call the framework Sharpy.  The code is hosted by Google Code &#8230; <a href="http://spechal.com/2010/12/16/sharpy/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>So I decided to start working on a rapid application development (RAD) framework for PHP the other day after a brief stint with Ruby on Rails.  I&#8217;ve decided to call the framework Sharpy.  The code is hosted by Google Code and can be found at <a href="http://code.google.com/p/sharpy/">http://code.google.com/p/sharpy/</a></p>
<p>I still need to add a database handler, internationalization, [lots more...] and refine the code comitted thus far, but it is a functional and small PHP MVC framework that supports templates.</p>
<p>Hopefully someone out there will find it useful.</p>
]]></content:encoded>
			<wfw:commentRss>http://spechal.com/2010/12/16/sharpy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Generate and validate UUID / GUID with PHP</title>
		<link>http://spechal.com/2010/10/18/generate-and-validate-uuid-guid/</link>
		<comments>http://spechal.com/2010/10/18/generate-and-validate-uuid-guid/#comments</comments>
		<pubDate>Mon, 18 Oct 2010 07:24:56 +0000</pubDate>
		<dc:creator>Spechal</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://spechal.com/?p=141</guid>
		<description><![CDATA[function UUID(){ return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0x0fff) &#124; 0x4000, mt_rand(0, 0x3fff) &#124; 0x8000, mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff)); } function validUUID($uuid){ return preg_match("#^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$#", $uuid); }]]></description>
			<content:encoded><![CDATA[<pre class="php">    function UUID(){
    	return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
        mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff),
        mt_rand(0, 0x0fff) | 0x4000,
        mt_rand(0, 0x3fff) | 0x8000,
        mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff));
    }

    function validUUID($uuid){
    	return preg_match("#^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$#", $uuid);
    }
</pre>
]]></content:encoded>
			<wfw:commentRss>http://spechal.com/2010/10/18/generate-and-validate-uuid-guid/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>phpize not found</title>
		<link>http://spechal.com/2009/12/06/phpize-not-found/</link>
		<comments>http://spechal.com/2009/12/06/phpize-not-found/#comments</comments>
		<pubDate>Sun, 06 Dec 2009 02:12:57 +0000</pubDate>
		<dc:creator>Spechal</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[apt-get]]></category>
		<category><![CDATA[phpize]]></category>
		<category><![CDATA[yum]]></category>

		<guid isPermaLink="false">http://spechal.com/?p=106</guid>
		<description><![CDATA[This error is typically generated when you don&#8217;t have the PHP development libraries installed. Installing the libraries via repository is the easiest and quickest fix. For Fedora/Red Hat: yum install php5-dev For Ubuntu/Debian: apt-get install php5-dev]]></description>
			<content:encoded><![CDATA[<p>This error is typically generated when you don&#8217;t have the PHP development libraries installed.</p>
<p>Installing the libraries via repository is the easiest and quickest fix.</p>
<p>For Fedora/Red Hat:<br />
yum install php5-dev</p>
<p>For Ubuntu/Debian:<br />
apt-get install php5-dev</p>
]]></content:encoded>
			<wfw:commentRss>http://spechal.com/2009/12/06/phpize-not-found/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Python MySQL Associative Array</title>
		<link>http://spechal.com/2009/11/27/python-mysql-associative-array/</link>
		<comments>http://spechal.com/2009/11/27/python-mysql-associative-array/#comments</comments>
		<pubDate>Fri, 27 Nov 2009 23:26:04 +0000</pubDate>
		<dc:creator>Spechal</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://spechal.com/?p=87</guid>
		<description><![CDATA[By default, the MySQLdb module to access a MySQL database returns the data as an integer indexed array. Sometimes this is not desirable and an associative array is preferred, such as the mysql_fetch_assoc function in PHP. In addition, we will &#8230; <a href="http://spechal.com/2009/11/27/python-mysql-associative-array/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>By default, the MySQLdb module to access a MySQL database returns the data as an integer indexed array.  Sometimes this is not desirable and an associative array is preferred, such as the mysql_fetch_assoc function in PHP.  In addition, we will be using the pprint module which is similar PHP&#8217;s print_r</p>
<p>Here is the Python equivalent:</p>
<pre class="python" name="code">
import MySQLdb
import pprint
# connect to the database here
db = MySQLdb.connect(...)
c = db.cursor(cursorclass=MySQLdb.cursors.DictCursor)
query = "SELECT `name`, `address` FROM `table`"
c.execute(query)
rows = c.fetchall()
c.close()
pprint.pprint(rows) # i.e. print_r($rows)
</pre>
<p>Hope that helps someone.</p>
]]></content:encoded>
			<wfw:commentRss>http://spechal.com/2009/11/27/python-mysql-associative-array/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

