<?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>edrackham &#187; Featured</title>
	<atom:link href="http://edrackham.com/category/featured/feed/" rel="self" type="application/rss+xml" />
	<link>http://edrackham.com</link>
	<description>PHP, MySQL, JavaScript and Other Web Tutorials!</description>
	<lastBuildDate>Tue, 21 Feb 2012 11:57:10 +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>Simple PHP MySQL Class</title>
		<link>http://edrackham.com/php/simple-php-mysql-class/</link>
		<comments>http://edrackham.com/php/simple-php-mysql-class/#comments</comments>
		<pubDate>Tue, 17 Aug 2010 20:50:35 +0000</pubDate>
		<dc:creator>Ed</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Class]]></category>

		<guid isPermaLink="false">http://edrackham.com/uncategorized/simple-php-mysql-class/</guid>
		<description><![CDATA[That&#8217;s right! I have a simple MySQL class file that you can use in your PHP projects. I&#8217;ve been using it for years, and it&#8217;s never let me down! You can grab it on my Github: http://github.com/a1phanumeric/PHP-MySQL-Class. Setup The setup is simple: Simply include this class into your project like so: include_once('/path/to/class.MySQL.php'); Then make sure [...]]]></description>
			<content:encoded><![CDATA[<p>That&#8217;s right! I have a simple MySQL class file that you can use in your PHP projects. I&#8217;ve been using it for years, and it&#8217;s never let me down!</p>
<p>You can grab it on my Github: <a href="http://github.com/a1phanumeric/PHP-MySQL-Class">http://github.com/a1phanumeric/PHP-MySQL-Class</a>.</p>
<p><span id="more-32"></span></p>
<h2>Setup</h2>
<p>The setup is simple:</p>
<p>Simply include this class into your project like so:</p>
<pre name="code" class="php">include_once('/path/to/class.MySQL.php');</pre>
<p>Then make sure you have the following definitions set:</p>
<pre name="code" class="php">MYSQL_HOST
MYSQL_USER
MYSQL_PASS
MYSQL_NAME</pre>
<p>I usually include them in a globally included config file.</p>
<p><div align="center" style="margin-bottom: 20px;">
<script type="text/javascript"><!--
google_ad_client = "pub-4159646232668987";
google_ad_slot = "5003066961";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div></p>
<p>MYSQL_HOST = The hostname of the MySQL server (usually, but not always, &#8216;localhost&#8217;).</p>
<p>MYSQL_USER = Your username for the server / database</p>
<p>MYSQL_PASS = Your password for the server / database</p>
<p>MYSQL_NAME = The name of your database</p>
<h2>Usage</h2>
<p>To use this class, you&#8217;d first init the object like so:</p>
<pre name="code" class="php">$oMySQL = new MySQL();</pre>
<p>The class constructor will perform a connection to the database automatically. To execute statements simply use:</p>
<pre name="code" class="php">$oMySQL->ExecuteSQL($query);</pre>
<p>There&#8217;s plenty more to do with this class, such as get instantly arrayed results using:</p>
<pre name="code" class="php">$oMySQL->ArrayResults();</pre>
<p>Or:</p>
<pre name="code" class="php">$oMySQL->ArrayResultsWithKey();</pre>
<p>So have a play and let me know what you think &#8230;or fork me!</p>
<p>The code is all here:</p>
<p><a href="http://github.com/a1phanumeric/PHP-MySQL-Class">http://github.com/a1phanumeric/PHP-MySQL-Class</a></p>
]]></content:encoded>
			<wfw:commentRss>http://edrackham.com/php/simple-php-mysql-class/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Get Random Row with MySQL Without ORDER BY RAND()</title>
		<link>http://edrackham.com/featured/get-random-row-with-mysql-without-order-by-rand/</link>
		<comments>http://edrackham.com/featured/get-random-row-with-mysql-without-order-by-rand/#comments</comments>
		<pubDate>Wed, 05 Mar 2008 12:12:24 +0000</pubDate>
		<dc:creator>Ed</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[fast]]></category>
		<category><![CDATA[random row]]></category>

		<guid isPermaLink="false">http://edrackham.com/mysql/get-random-row-with-mysql-without-rand/</guid>
		<description><![CDATA[This is an update to a previous post of mine which uses the RAND() method. Using the following code, you can retrieve a random row much, much faster (MySQL 4.1.x/5.0.x), with thanks to Jan Kneschke: SELECT FROM AS r1 JOIN (SELECT ROUND( RAND( ) * ( SELECT MAX( id ) FROM ) ) AS id [...]]]></description>
			<content:encoded><![CDATA[<p>This is an update to a <a href="http://edrackham.com/php/get-random-row-with-mysql/" title="Slower, but useful for smaller tables">previous post of mine</a> which uses the RAND() method. Using the following code, you can retrieve a random row much, much faster (MySQL 4.1.x/5.0.x), with thanks to Jan Kneschke:</p>
<p>SELECT <COLUMN> FROM <TABLE> AS r1<br />
JOIN (SELECT ROUND(<br />
  RAND( ) * (<br />
    SELECT MAX( id ) FROM <TABLE>)<br />
  ) AS id<br />
) AS r2<br />
WHERE r1.id >= r2.id<br />
ORDER BY r1.id ASC<br />
LIMIT 1;</pre>
<p><div align="center" style="margin-bottom: 20px;">
<script type="text/javascript"><!--
google_ad_client = "pub-4159646232668987";
google_ad_slot = "5003066961";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div></p>
<p>Replace:</p>
<ul>
<li><strong>&lt;COLUMN&gt;</strong> with the name of the column(s) you wish to retrieve</li>
<li><strong>&lt;TABLE&gt;</strong> with the name of the table you wish to retrieve the data from</li>
</ul>
<p>I've tested this with a table with over 660,000 records, and got a response in 0.0200 seconds, whereas with ORDER BY RAND() i got a response in 2.1599 seconds.</p>
<h4>Total Number of Rows:</h4>
<p><img src="http://edrackham.com/images/posts/num-rows.gif" alt="Cardinality" style="border:1px solid #ccc" /></p>
<h4>Old Method:</h4>
<p><img src="http://edrackham.com/images/posts/faster-rand-mysql-old-query.gif" alt="Old Method" style="border:1px solid #ccc" /></p>
<h4>New Method:</h4>
<p><img src="http://edrackham.com/images/posts/faster-rand-mysql-new-query.gif" alt="New Method" style="border:1px solid #ccc" /></p>
<p><div align="center" style="margin-bottom: 20px;">
<script type="text/javascript"><!--
google_ad_client = "pub-4159646232668987";
google_ad_slot = "5003066961";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div></p>
]]></content:encoded>
			<wfw:commentRss>http://edrackham.com/featured/get-random-row-with-mysql-without-order-by-rand/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
	</channel>
</rss>

