<?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>Monkey Business &#187; validation</title>
	<atom:link href="http://blog.supadupa.co.za/index.php/tag/validation/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.supadupa.co.za</link>
	<description>Confessions of a webaholic</description>
	<lastBuildDate>Thu, 02 Sep 2010 15:38:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>Validation: lookup against international dialling codes</title>
		<link>http://blog.supadupa.co.za/index.php/2009/10/validation-lookup-against-international-dialling-codes/</link>
		<comments>http://blog.supadupa.co.za/index.php/2009/10/validation-lookup-against-international-dialling-codes/#comments</comments>
		<pubDate>Fri, 30 Oct 2009 21:00:34 +0000</pubDate>
		<dc:creator>murraybiscuit</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[calling]]></category>
		<category><![CDATA[codes]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[validation]]></category>

		<guid isPermaLink="false">http://blog.supadupa.co.za/?p=97</guid>
		<description><![CDATA[I don&#8217;t normally post code samples, but this one might come in handy for somebody building a calling app. Given the following scenario, you&#8217;d do the following: 1. Get the number the user wants to call 2. Run it against a table with available dialling codes 3. Return a single matching record You&#8217;d normally do [...]]]></description>
			<content:encoded><![CDATA[<p>I don&#8217;t normally post code samples, but this one might come in handy for somebody building a calling app. Given the following scenario, you&#8217;d do the following:</p>
<p>1. Get the number the user wants to call<br />
2. Run it against a table with available dialling codes<br />
3. Return a single matching record</p>
<p>You&#8217;d normally do this by forward / backward recursing through each character of the test number until you found the longest match and then return that. This would require a server-side loop with a db call on each iteration.</p>
<p>I found a much quicker way of doing this with the following sql query:</p>
<p><code>select *<br />
from `{table_name}`<br />
where {test_number} like(concat(`{codes_column}`,'%'))<br />
order by `{codes_column}` desc<br />
limit 1</code></p>
<p>It&#8217;s really quick to execute on a large table. Hopefully it comes in handy for someone looking for it.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.supadupa.co.za/index.php/2009/10/validation-lookup-against-international-dialling-codes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

