<?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>Dan Hulton&#039;s blog &#187; mysql</title>
	<atom:link href="http://www.danhulton.com/blog/tag/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.danhulton.com/blog</link>
	<description>Coffee, code, contemplation.</description>
	<lastBuildDate>Tue, 31 Aug 2010 14:36:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>New in PHP 5.3</title>
		<link>http://www.danhulton.com/blog/2009/04/06/new-in-php-53/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=new-in-php-53</link>
		<comments>http://www.danhulton.com/blog/2009/04/06/new-in-php-53/#comments</comments>
		<pubDate>Mon, 06 Apr 2009 21:23:26 +0000</pubDate>
		<dc:creator>Dan Hulton</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[lambdas]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[mysqlnd]]></category>
		<category><![CDATA[namespaces]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[ternary]]></category>

		<guid isPermaLink="false">http://www.danhulton.com/blog/?p=116</guid>
		<description><![CDATA[PHP is approaching another important release, version 5.3. The release candidate is already available, if you&#8217;re interested in trying things out early. I thought I&#8217;d take a moment however, and highlight four really interesting new features we can expect in this new release. 1) Namespaces Adding namespaces solves, in a stroke, a great many conflicts [...]]]></description>
			<content:encoded><![CDATA[<p>PHP is approaching another important release, version 5.3.  <a href="http://www.php.net/archive/2009.php#id2009-03-24-1">The release candidate is already available</a>, if you&#8217;re interested in trying things out early.  I thought I&#8217;d take a moment however, and highlight four really interesting new features we can expect in this new release.</p>
<h2>1) <a href="http://ca.php.net/namespaces">Namespaces</a></h2>
<p>Adding namespaces solves, in a stroke, a great many conflicts that developers tend to run into with PHP.  For example, if I write a database layer class called db and YOU write a database layer called db, and I try to include another library that you&#8217;ve written that references your database layer, I&#8217;m boned.  Since they&#8217;re both declared globally, this attempt at code re-use fails.</p>
<p>However, if I write a database layer and I decide to put it in the &#8220;danhulton&#8221; namespace, and you put yours in the &#8220;anotherlibrary&#8221; namespace, we&#8217;re fine.  I refer to &#8220;danhulton\db&#8221; and you refer to &#8220;anotherlibrary\db&#8221; and all is right in the world.</p>
<p>Sadly, the namespace delimiter they&#8217;ve chosen is the backslash, which to my eyes just looks ODD, and also can run you into issues if you ever have to put your namespace in a string (with backslash being the escape character).  Still, this is a net win for writing shareable PHP code.</p>
<h2>2) <a href="http://docs.php.net/functions.anonymous">Anonymous Functions</a></h2>
<p>I got into the habit of using anonymous functions liberally in javascript, and have come to sorely miss them in PHP.  Sure, you can emulate them with create_function(), but the syntax is awkward and the resource cost prohibitive.  As of PHP 5.3, we&#8217;ll be able do do something a little like this:</p>
<pre class="prettyprint"><code>$escaped = array_map(function($value) {
    return "'" . $value . "'";
}, array('sql', 'parameters', 'that', 'need', 'escaping'));</code></pre>
<p>I&#8217;m very much looking forward to the cleaner code this will allow me to produce.</p>
<h2>3) <a href="http://ca.php.net/ternary#language.operators.comparison.ternary">Ternary (?:) Operator</a></h2>
<p>The ternary operator already exists in PHP, and I use it frequently.  It allows you to do something like this:</p>
<pre class="prettyprint"><code>$colour = ($balance > 0) ? 'green' : 'red';</code></pre>
<p>Or, if you need to ensure a value is set before using it, you can write:</p>
<pre class="prettyprint"><code>$entries = isset($entries) ? $entries : array();</code></pre>
<p>In PHP 5.3, you&#8217;ll be able to simply write:</p>
<pre class="prettyprint"><code>$entries = $entries ?: array();</code></pre>
<p>Which means you can also write:</p>
<pre class="prettyprint"><code>foreach ($entries ?: array() as $entry) {
    // some stuff
}</code></pre>
<p>This change is excellent because, again, it leads to cleaner code.</p>
<h2>4) <a href="http://ca3.php.net/mysqli.mysqlnd">Native MySQL library driver</a></h2>
<p>This should be a huge win for many applications which value efficiency.  (Although, isn&#8217;t that all of them?)  The MySQL native driver is a full replacement for the currently-used driver written my MySQL AB.  It is more efficient in terms of memory usage (storing all rows only once instead of twice), and should be just as processor-friendly, if not more.  Further, there are a host of performance statistics calls that should ensure that performance debugging is much easier, and they include a function I wish had been there from the beginning: <a href="http://ca3.php.net/manual/en/mysqli-result.fetch-all.php">mysqli_fetch_all()</a>.  No more having to write a big while() loop with mysql_fetch_assoc(), this baby will take care of you in one line.</p>
<p>Now, since I&#8217;ve switched to the <a href="http://kohanaphp.com/">Kohana framework</a>, my database functions are a lot friendlier already, so the latter function won&#8217;t specifically change how I code.  But the decreased memory costs, especially for queries that return many rows, will be fantastic.</p>
<h2>Conclusion</h2>
<p>PHP 5.3 is going to be an excellent addition to the language, one I can&#8217;t wait for.  I expect a fair amount of grumbling as we get adjusted to all the new features, and I&#8217;m rather curious to see what Kohana and other frameworks decide to do with regard to support (ideally for Kohana, IMHO, is keep KO 2.3 compatable with PHP 5.2.9, but require PHP 5.3 for KO 2.4 and 3.0).  However, in the long run, we&#8217;ll have the ability to write cleaner, clearer, and <em>less</em> code, and that will be a fantastic advantage.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.danhulton.com/blog/2009/04/06/new-in-php-53/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>FireStick 1.0 &#8211; Performance logging add-on library for CodeIgniter</title>
		<link>http://www.danhulton.com/blog/2008/09/22/firestick-10-performance-logging-add-on-library-for-codeigniter/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=firestick-10-performance-logging-add-on-library-for-codeigniter</link>
		<comments>http://www.danhulton.com/blog/2008/09/22/firestick-10-performance-logging-add-on-library-for-codeigniter/#comments</comments>
		<pubDate>Mon, 22 Sep 2008 20:36:21 +0000</pubDate>
		<dc:creator>Dan Hulton</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[benchmarking]]></category>
		<category><![CDATA[codeigniter]]></category>
		<category><![CDATA[firestick]]></category>
		<category><![CDATA[gpl]]></category>
		<category><![CDATA[logging]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[performance]]></category>

		<guid isPermaLink="false">http://www.danhulton.com/blog/?p=57</guid>
		<description><![CDATA[From the announcement post on the CodeIgniter forums: FireStick is a (relatively) simple to configure library that enables easy and low-overhead performance logging in CodeIgniter. Performance measuring and logging is an important part of application maintenance and improvement. FireStick makes it easy to record page render times, MySQL call times, and other related information that [...]]]></description>
			<content:encoded><![CDATA[<p>From the <a href="http://codeigniter.com/forums/viewthread/91696/">announcement post on the CodeIgniter forums</a>:</p>
<blockquote><p>FireStick is a (relatively) simple to configure library that enables easy and low-overhead performance logging in CodeIgniter. </p>
<p>Performance measuring and logging is an important part of application maintenance and improvement.  FireStick makes it easy to record page render times, MySQL call times, and other related information that you can use to track down performance issues. </p>
<p>FireStick relies on CodeIgniter’s built-in performance and benchmarking capabilities and a post-system hook.  When the hook is called, FireStick logs all this information to the database for review at a later date. </p>
<p>Logs are split up into multiple tables based on date, with each new day’s table created automatically on the first request of each new day.  All logs are added using INSERT DELAYED so as to minimize impact on the database server. </p>
<p>Main project page: <a href="http://code.google.com/p/firestick/">http://code.google.com/p/firestick/</a><br />
Project source: <a href="http://firestick.googlecode.com/files/firestick-1.0.zip">http://firestick.googlecode.com/files/firestick-1.0.zip</a><br />
Installation instructions: <a href="http://code.google.com/p/firestick/wiki/Installation">http://code.google.com/p/firestick/wiki/Installation</a></p></blockquote>
<p>I&#8217;ve been reading <a href="http://www.amazon.com/High-Performance-MySQL-Optimization-Replication/dp/0596101716/ref=pd_bbs_sr_1?ie=UTF8&#038;s=books&#038;qid=1222115234&#038;sr=1-1">High Performance MySQL</a> lately, and the very first section of the book is on profiling, why it&#8217;s a good idea, and how to go about doing it.  Since I&#8217;ve deployed <a href="http://www.danhulton.com/comingup/">ComingUp</a> out in the wild, I figured <em>I</em> should be profiling, too.</p>
<p>So I put together this little add-on library for CodeIgniter that takes the basics presented in the text and adapts them to CodeIgniter&#8217;s already well-rounded benchmark system.  CodeIgniter already has total script execution time measured, total script memory consumption, and a full list of all DB calls and the amount of time they took.  I just collated all of that and put it into a sensible DB logging system.</p>
<p>The whole deal is open source, too.  GPL v3.  Any CodeIgniter developer anywhere can feel free to use this, and I&#8217;d be happy if they did.</p>
<p>If you are using it, and you encounter any bugs or want to provide feedback, please leave a comment in <a href="http://codeigniter.com/forums/viewthread/91696/">the FireStick thread on the CodeIgniter forums</a>, and I&#8217;ll be happy to address it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.danhulton.com/blog/2008/09/22/firestick-10-performance-logging-add-on-library-for-codeigniter/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
