<?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>Matthew Elliston &#187; PHP</title>
	<atom:link href="http://www.matthewelliston.com/category/development/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.matthewelliston.com</link>
	<description>A site filled with my pictures, thoughts and things I want to remember!</description>
	<lastBuildDate>Wed, 24 Aug 2011 14:03:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>Error parsing XML; message from parser is: The entity &#8220;Acirc&#8221; was referenced, but not declared.</title>
		<link>http://www.matthewelliston.com/error-parsing-xml-message-from-parser-is-the-entity-acirc-was-referenced-but-not-declared/</link>
		<comments>http://www.matthewelliston.com/error-parsing-xml-message-from-parser-is-the-entity-acirc-was-referenced-but-not-declared/#comments</comments>
		<pubDate>Tue, 31 May 2011 16:12:26 +0000</pubDate>
		<dc:creator>Matthew</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.matthewelliston.com/?p=147</guid>
		<description><![CDATA[Recently I stumbled upon an error while trying to pass a shopping cart to the payment provider Google Checkout. The error was: &#8220;Error parsing XML; message from parser is: The entity &#8220;Acirc&#8221; was referenced, but not declared.&#8221; After hunting around and a bit of searching on the net, the issued stemmed from having a `&#163;`<a href="http://www.matthewelliston.com/error-parsing-xml-message-from-parser-is-the-entity-acirc-was-referenced-but-not-declared/" class="read-more">Continue Reading</a>]]></description>
			<content:encoded><![CDATA[<p>Recently I stumbled upon an error while trying to pass a shopping cart to the payment provider Google Checkout.</p>
<p>The error was: </p>
<p><em>&#8220;Error parsing XML; message from parser is: The entity &#8220;Acirc&#8221; was referenced, but not declared.&#8221;</em></p>
<p>After hunting around and a bit of searching on the net, the issued stemmed from having a `&pound;` in a product&#8217;s option name. Removing the `&pound;` sign seemed to fix the issue. So if you ever run into this issue it would be wise to check if there are any &pound; signs in your xml.</p>
<p>Strange error so I thought I would note it here for future ref and others to see.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.matthewelliston.com/error-parsing-xml-message-from-parser-is-the-entity-acirc-was-referenced-but-not-declared/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Copyright Year.</title>
		<link>http://www.matthewelliston.com/copyright-year/</link>
		<comments>http://www.matthewelliston.com/copyright-year/#comments</comments>
		<pubDate>Mon, 04 Jan 2010 09:23:46 +0000</pubDate>
		<dc:creator>Matthew</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.matthewelliston.com/?p=125</guid>
		<description><![CDATA[Just a quick post but it is one that I had to use recently so thought I would quickly make a note of it so that it helps others out. With the new year coming I had to update a sites copyright year which was displayed in the footer. It was a simple enough thing<a href="http://www.matthewelliston.com/copyright-year/" class="read-more">Continue Reading</a>]]></description>
			<content:encoded><![CDATA[<p>Just a quick post but it is one that I had to use recently so thought I would quickly make a note of it so that it helps others out.</p>
<p>With the new year coming I had to update a sites copyright year which was displayed in the footer. It was a simple enough thing to do but I feared that I would need to be doing it again this time next year.</p>
<p>The solution was to use PHP to output the current year.</p>
<pre class="brush: php">
   echo date("Y");
</pre>
<p>If your server doesn&#8217;t support PHP check see if there are any other server side scripting languages such as ASP, Perl, Python or Ruby etc They all have similar functions for returning the current year.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.matthewelliston.com/copyright-year/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PHP Scaffolding Class</title>
		<link>http://www.matthewelliston.com/php-scaffolding-class/</link>
		<comments>http://www.matthewelliston.com/php-scaffolding-class/#comments</comments>
		<pubDate>Sat, 15 Aug 2009 21:11:53 +0000</pubDate>
		<dc:creator>Matthew</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.matthewelliston.com/?p=101</guid>
		<description><![CDATA[Im uploading this scaffolding class so that hopefully some other people can find use for it. It is based on the excellent tutorial on building a scaffolding class by Ben Hirsch which can be found here http://www.shadow-fox.net/site/tutorial/39-Creating-A-Scaffold-like-Class-in-PHP-or-An-Automatic-CMS-For-a-Table Sadly i can&#8217;t seem to find the original post however I&#8217;m sure its nothing a quick google can&#8217;t<a href="http://www.matthewelliston.com/php-scaffolding-class/" class="read-more">Continue Reading</a>]]></description>
			<content:encoded><![CDATA[<p>Im uploading this scaffolding class so that hopefully some other people can find use for it. It is based on the excellent tutorial on building a scaffolding class by Ben Hirsch which can be found here http://www.shadow-fox.net/site/tutorial/39-Creating-A-Scaffold-like-Class-in-PHP-or-An-Automatic-CMS-For-a-Table Sadly i can&#8217;t seem to find the original post however I&#8217;m sure its nothing a quick google can&#8217;t fix.</p>
<p>There is a link to the download at the end of this post.</p>
<p>I have used it to get projects going quickly. It can be pointed to a mysql database and can read the tables in etc and generate the CReate Update and Delete (CRUD) similar to how ruby on rails has scaffolding.</p>
<p>It is by no means perfect and could do with some refinements here and there. It is however quite functional in its current state and has support for foreign keys and image uploads.</p>
<p>There are some naming conventions to be adhered to if you want to get the most out of this. However you can quickly go through it and change these to whatever you like.</p>
<p>Here is a list of column names and how the Scaffolding Class reacts to them:</p>
<table>
<tr>
<th>Column Name</th>
<th>Data Type</th>
<th>Scaffolding Output</th>
</tr>
<tr>
<td>image_url</td>
<td>varchar(255)</td>
<td>Image Upload Field</td>
</tr>
<tr>
<td></td>
<td>varchar</td>
<td>Text Input</td>
</tr>
<tr>
<td></td>
<td>text</td>
<td>Textarea</td>
</tr>
<tr>
<td>&#8220;foreigntable_id&#8221;</td>
<td>INT</td>
<td>Outputs the &#8220;name&#8221; field from the lookup table &#8220;foreigntable&#8221;</td>
</tr>
<tr>
<td></td>
<td>datetime</td>
<td>A date/time drop down selector.</td>
</tr>
<tr>
<td>Last three characters &#8216;_on&#8217;</td>
<td>INT</td>
<td>A Yes/No drop down selector.</td>
</tr>
</table>
<p>I have used this for many projects to get them off the ground. For simple admin areas it works perfectly. </p>
<p>Would love to hear your thoughts and comments.</p>
<p><a href="http://www.matthewelliston.com/code/Scaffolding.zip" title="PHP Scaffolding Class">Download Scaffolding.zip</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.matthewelliston.com/php-scaffolding-class/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>PHP Singleton Database Class</title>
		<link>http://www.matthewelliston.com/php-singleton-database-class/</link>
		<comments>http://www.matthewelliston.com/php-singleton-database-class/#comments</comments>
		<pubDate>Tue, 12 May 2009 21:14:16 +0000</pubDate>
		<dc:creator>Matthew</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Database Class]]></category>
		<category><![CDATA[Singleton Database Class]]></category>

		<guid isPermaLink="false">http://www.matthewelliston.com/?p=67</guid>
		<description><![CDATA[A php singleton database class which allows your database queries to be performed quickly and with very few lines of code.]]></description>
			<content:encoded><![CDATA[<p>Hi this is my first post in the way of development on my blog.</p>
<p>I have decided to upload my database class that I use for projects. Its by no means perfect. There is quite a heated debate on Singleton classes themselves. However I like how it works for me. I can query query a database quicklyby simply using:</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php

$db = Database::getInstance();
$results = $db-&amp;gt;query(&quot;SELECT * FROM test WHERE name = :name&quot;,array(&quot;:name&quot; =&amp;gt; &quot;matthew&quot;));

print_r($results);

?&gt;
</pre>
<p><span id="more-67"></span></p>
<p>The function query can be passed an array of arguments that can be used when wanting to sanitize the data before querying the database. This uses the standard PDO::prepare() function to create the prepared statement. It can accept the :foo or ? format of statement.</p>
<p>Here is the full listing of the class.</p>
<pre class="brush: php">
&lt;?php
/**
* Database access class.
* Used in applications where one point of database access is required
*
* Typical Usage:
* $db = Database::getInstance();
* $results = $db-&gt;query("SELECT * FROM test WHERE name = :name",array(":name" =&gt; "matthew"));
* print_r($results);
*
* @author Matthew Elliston &lt;matt@e-titans.com&gt;
* @version 1.0
*/
class Database {

/**
* Instance of the database class
* @static Database $instance
*/
private static $instance;
/**
* Database connection
* @access private
* @var PDO $connection
*/
private $connection;

/**
* Constructor
* @param $dsn The Data Source Name. eg, "mysql:dbname=testdb;host=127.0.0.1"
* @param $username
* @param $password
*/
private function __construct(){
$this-&gt;connection = new PDO("mysql:dbname=spaceinteriors;host=127.0.0.1","root","");
$this-&gt;connection-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}

/**
* Gets an instance of the Database class
*
* @static
* @return Database An instance of the database singleton class.
*/
public static function getInstance(){
if(empty(self::$instance)){
try{
self::$instance = new Database();
} catch (PDOException $e) {
echo 'Connection failed: ' . $e-&gt;getMessage();
}
}
return self::$instance;
}

/**
* Runs a query using the current connection to the database.
*
* @param string query
* @param array $args An array of arguments for the sanitization such as array(":name" =&gt; "foo")
* @return array Containing all the remaining rows in the result set.
*/
public function query($query, $args){
$tokens = explode(" ",$query);
try{
$sth = $this-&gt;connection-&gt;prepare($query);
if(empty($args)){
$sth-&gt;execute();
}
else{
$sth-&gt;execute($args);
}
if($tokens[0] == "SELECT"){
$sth-&gt;setFetchMode(PDO::FETCH_ASSOC);
$results = $sth-&gt;fetchAll();
return $results;
}
} catch (PDOException $e) {
echo 'Query failed: ' . $e-&gt;getMessage();
echo '&lt;br /&gt;Query : ' . $query;
}
return 1;
}

/**
* Returns the last inserted ID
*
* @return int ID of the last inserted row
*/
public function lastInsertId(){
return $this-&gt;connection-&gt;lastInsertId();
}
}
?&gt;
</pre>
<p>Please let me know your thoughts on this and any tips to improve it.</p>
<p>I don&#8217;t claim it to be perfect but it fits what I need, so please be kind!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.matthewelliston.com/php-singleton-database-class/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

