<?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>evardsson.com: stuff that w0rks &#187; Projects</title>
	<atom:link href="http://www.evardsson.com/blog/category/projects/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.evardsson.com/blog</link>
	<description>tweaks and hacks, php, python, music, home and ???</description>
	<lastBuildDate>Mon, 23 Jan 2012 18:38:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>New Project: SPDO</title>
		<link>http://www.evardsson.com/blog/2009/01/28/new-project-spdo/</link>
		<comments>http://www.evardsson.com/blog/2009/01/28/new-project-spdo/#comments</comments>
		<pubDate>Thu, 29 Jan 2009 02:00:40 +0000</pubDate>
		<dc:creator>Sjan Evardsson</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PostgresQL]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[SPDO]]></category>
		<category><![CDATA[sqlite]]></category>

		<guid isPermaLink="false">http://www.evardsson.com/blog/?p=284</guid>
		<description><![CDATA[I have just posted the (embarrassingly empty) page for my new pet project: SPDO (Sjan&#8217;s PDO) &#8211; in two flavors: PHP and Python. There are only about a thousand PDOs out there, and perhaps a dozen or so of them are really functional and (in a few cases) very polished pieces of work. So why [...]]]></description>
			<content:encoded><![CDATA[<p>I have just posted the (embarrassingly empty) page for my new pet project: SPDO (Sjan&#8217;s PDO) &#8211; in two flavors: <a href="http://www.php.net">PHP</a> and <a href="http://python.org/">Python</a>.</p>
<p>There are only about a thousand PDOs out there, and perhaps a dozen or so of them are really functional and (in a few cases) very polished pieces of work. So why am I messing with writing my own? A couple of reasons:</p>
<ol>
<li>I like to have coding signatures that are consistent, whether I am working with <a href="http://www.postgresql.org/">PostgreSQL</a>, <a href="http://www.mysql.com/">MySQL</a> or (heaven help us all) <a href="http://www.sqlite.org/">SQLite</a>.</li>
<li>I like to have coding signatures that are (reasonably) consistent across different languages &#8211; in this case Python and PHP.</li>
<li>I wanted to take advantage of Prepared Statements where I could, even though the PHP implementations of those are pretty weak (especially in the case of MySQL).</li>
</ol>
<p>Currently implemented in</p>
<ul>
<li>Python:
<ul>
<li>PostgreSQL (with prepared statements)</li>
<li>SQLite (no prepared statements).</li>
</ul>
</li>
<li>PHP
<ul>
<li>PostgreSQL (with prepared statements)</li>
<li>MySQL (with prepared statements)</li>
<li>SQLite (no prepared statements)</li>
</ul>
</li>
</ul>
<p>Here&#8217;s an example of how they work (in most simplistic terms):</p>
<pre class="brush: python">
#in Python
from pyDB import *
db = pyDB('mysite')
newid = db.insert('INSERT INTO test (name, value) VALUES (?,?)',['foo','bar'])
update_count = db.update('UPDATE test SET value=? WHERE id=?',['baz',newid])
results = db.select('SELECT * FROM test')
for row in results:
    for i in row:
        print "\t", i,"\t", row[i]
delete_count = db.delete('DELETE FROM test WHERE id=?',[newid])
</pre>
<pre class="brush: php">
//in PHP
require_once('phpdb.php');
$db = new phpDB('test');
$newid = $db->insert('INSERT INTO test (name, value) VALUES (?,?)',array('foo','bar'));
$update_count = $db->update('UPDATE test SET value=? WHERE id=?',array('baz',newid));
$results = db->select('SELECT * FROM test');
foreach($results as $row)
{
    foreach ($row as $key=>$val)
    {
        print "\t$key\t$val";
    }
}
$delete_count = $db->delete('DELETE FROM test WHERE id=?',array($newid));
</pre>
<p>The page with links to the code is in the list up top, and everything is MIT license. Enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.evardsson.com/blog/2009/01/28/new-project-spdo/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

