<?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>Trent Richardson &#187; Database</title> <atom:link href="http://trentrichardson.com/category/database/feed/" rel="self" type="application/rss+xml" /><link>http://trentrichardson.com</link> <description>practical web design &#38; development</description> <lastBuildDate>Wed, 25 Jan 2012 11:43:16 +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>Return Multiple Result Sets with PHP and PostgreSQL Functions</title><link>http://trentrichardson.com/2012/01/04/return-multiple-result-sets-with-php-and-postgresql-functions/</link> <comments>http://trentrichardson.com/2012/01/04/return-multiple-result-sets-with-php-and-postgresql-functions/#comments</comments> <pubDate>Wed, 04 Jan 2012 11:45:24 +0000</pubDate> <dc:creator>trent</dc:creator> <category><![CDATA[Database]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[Windows]]></category> <category><![CDATA[cursor]]></category> <category><![CDATA[functions]]></category> <category><![CDATA[postgresql]]></category> <category><![CDATA[procedures]]></category> <category><![CDATA[results]]></category> <category><![CDATA[return]]></category> <category><![CDATA[stored]]></category><guid
isPermaLink="false">http://trentrichardson.com/?p=1061</guid> <description><![CDATA[A while back I discussed how to use the new sqlsrv extension for php to retrieve multiple result sets at a time from stored proceedures. This was indeed helpful when you need to retrieve related data and avoid multiple calls to stored proceedures. The down side is this was using a rather expensive (but good) [...]
Related posts:<ol><li><a
href='http://trentrichardson.com/2011/08/10/making-sense-of-stored-procedures-with-php-pdo-and-sqlsrv/' rel='bookmark' title='Making Sense of Stored Procedures with PHP, PDO, and Sqlsrv'>Making Sense of Stored Procedures with PHP, PDO, and Sqlsrv</a></li><li><a
href='http://trentrichardson.com/2010/12/01/thought-is-else-return-really-necessary/' rel='bookmark' title='Thought: Is else return really necessary?'>Thought: Is else return really necessary?</a></li><li><a
href='http://trentrichardson.com/2010/01/31/cakephp-postgresql-and-regex/' rel='bookmark' title='CakePHP, PostgreSQL, and Regex'>CakePHP, PostgreSQL, and Regex</a></li></ol>]]></description> <content:encoded><![CDATA[<p>A while back I discussed how to use the new sqlsrv extension for php to <a
href="http://trentrichardson.com/2011/08/10/making-sense-of-stored-procedures-with-php-pdo-and-sqlsrv/" title="SQL Server Stored Proceedures with PHP, PDO, and SQLSrv">retrieve multiple result sets at a time from stored proceedures</a>.  This was indeed helpful when you need to retrieve related data and avoid multiple calls to stored proceedures.  The down side is this was using a rather expensive (but good) database engine.  Also, <a
href="http://www.microsoft.com/download/en/details.aspx?id=28160" title="SQLSrv PHP extension for linux" target="_blank">until recently</a>, there was absolutely no support for the sqlsrv php extension on unix based servers.  How can the open source world tap into such functionality?</p><p>PostgreSQL has the ability to return multiple cursors to result sets.  Using this we can achieve the same effect with php with a little magic.  Lets take a look at a simple function which returns three queries by way of refcursor type.  Also not that I said &#8220;function&#8221;, not &#8220;procedure&#8221;, but never fear, 6 of one, half dozen of the other as far as this topic goes:</p><pre><code class="sql">
CREATE OR REPLACE FUNCTION test_get_users(userID integer) RETURNS SETOF refcursor AS $$

	DECLARE
		ref1 refcursor;
		ref2 refcursor;
		ref3 refcursor;
	BEGIN

	OPEN ref1 FOR
		SELECT id, name, email FROM users;
	RETURN NEXT ref1;

	OPEN ref2 FOR
		SELECT id FROM users WHERE is_active=1;
	RETURN next ref2;

	OPEN ref3 FOR
		SELECT * FROM users WHERE id = userID;
	RETURN next ref3;

	RETURN;

END;
$$ LANGUAGE plpgsql;
</code></pre><p><span
id="more-1061"></span></p><p><a
href="http://trentrichardson.com/wp-content/uploads/2012/01/pg_test_get_users.jpg"><img
src="http://trentrichardson.com/wp-content/uploads/2012/01/pg_test_get_users.jpg" alt="" title="pg_test_get_users" width="200" height="111" class="alignright size-full wp-image-1065" /></a></p><p>So that is pretty simple, we run 3 select queries, and return the refcursor for those.  Now the tricky part will be how to read each of these queries on the php end.  The values returned from calling this function will resemble the image presented here.  These merely represent references to the cursors to each query run, so we will have to use some pg magic to pull those result sets in.  It boils down to we need to make one call to the function, then a separate call per result set to bring in those results (note the query has run at this point, its basically reading in the data, which should be quick).  Lets look at the SQL which would achieve this:<pre><code class="sql">
BEGIN;
SELECT test_get_users(2);
FETCH ALL IN "&lt;unnamed portal 1&gt;";
FETCH ALL IN "&lt;unnamed portal 2&gt;";
FETCH ALL IN "&lt;unnamed portal 3&gt;";
END;
</code></pre><p>Now it should make a little more sense what has to happen.  We call a fetch for each result set to return. So now we just need to process this with PHP:</p><pre><code class="php">
$conn = new PDO("pgsql:host=localhost;port=5432;dbname=testing", "username", "password");

$userID = 2;

// begin transaction, this is all one process
$conn-&gt;beginTransaction();

	// call the function
	$stmt = $conn-&gt;prepare("select test_get_users(:userID)");
	$stmt-&gt;bindParam('userID', $userID, PDO::PARAM_INT);
	$stmt-&gt;execute();
	$cursors = $stmt-&gt;fetchAll();
	$stmt-&gt;closeCursor();

	// get each result set
	$results = array();
	foreach($cursors as $k=&gt;$v){
		$stmt = $conn-&gt;query('FETCH ALL IN "'. $v[0] .'";');
		$results[$k] = $stmt-&gt;fetchAll();
		$stmt-&gt;closeCursor();
	}
$conn-&gt;commit();
unset($stmt);

echo '&lt;pre&gt;';
print_r($results);echo "\n"; // all record sets
echo '&lt;/pre&gt;';
</code></pre><p>Now first off, we call the select test_get_users(), which returns a list of refcursor names.  So with this we know how many queries were returned.  Just loop through this list and fetch each result set.  It is essentially the same process used from the Sql Server example, except the nextRowset() is not yet implemented for the pdo pgsql extension, so we just manually call the fetch.  No Biggie. You would then receive something similar to the following:</p><pre><code>
Array
(
	[0] =&gt; Array
		(
			[0] =&gt; Array
				(
					[id] =&gt; 2
					[0] =&gt; 2
					[name] =&gt; John Doe
					[1] =&gt; John Doe
					[email] =&gt; test2@test.com
					[2] =&gt; test2@test.com
				)

			[1] =&gt; Array
				(
					[id] =&gt; 3
					[0] =&gt; 3
					[name] =&gt; Jane Doe
					[1] =&gt; Jane Doe
					[email] =&gt; test3@test.com
					[2] =&gt; test3@test.com
				)

			......

		)

	[1] =&gt; Array
		(
			[0] =&gt; Array
				(
					[id] =&gt; 3
					[0] =&gt; 3
				)

			[1] =&gt; Array
				(
					[id] =&gt; 1
					[0] =&gt; 1
				)

		)

	[2] =&gt; Array
		(
			[0] =&gt; Array
				(
					[id] =&gt; 2
					[0] =&gt; 2
					[name] =&gt; John Doe
					[1] =&gt; John Doe
					[email] =&gt; test2@test.com
					[2] =&gt; test2@test.com
					[password] =&gt; zxcvxcvczxcv
					[3] =&gt; zxcvxcvczxcv
					[is_active] =&gt; 0
					[4] =&gt; 0
				)

		)

)
</code></pre><p>If you&#8217;re still feeling frisky at this point, there are all sorts of ways to &#8220;fetch&#8221; the result sets, just take a look at the <a
href="http://www.postgresql.org/docs/9.1/static/plpgsql-cursors.html" title="Postgresql Cursor Docs" target="_blank">docs on cursors</a>.  The more I use PostgreSQL the more I am becoming a fan.  It&#8217;s power and features go far beyond my skill set, but it feels good always knowing you have the best tool at hand for whatever task you have ahead of you.  As always feel free to chime in and leave any knowledge you may have, especially on Postgres!</p><p>Related posts:<ol><li><a
href='http://trentrichardson.com/2011/08/10/making-sense-of-stored-procedures-with-php-pdo-and-sqlsrv/' rel='bookmark' title='Making Sense of Stored Procedures with PHP, PDO, and Sqlsrv'>Making Sense of Stored Procedures with PHP, PDO, and Sqlsrv</a></li><li><a
href='http://trentrichardson.com/2010/12/01/thought-is-else-return-really-necessary/' rel='bookmark' title='Thought: Is else return really necessary?'>Thought: Is else return really necessary?</a></li><li><a
href='http://trentrichardson.com/2010/01/31/cakephp-postgresql-and-regex/' rel='bookmark' title='CakePHP, PostgreSQL, and Regex'>CakePHP, PostgreSQL, and Regex</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://trentrichardson.com/2012/01/04/return-multiple-result-sets-with-php-and-postgresql-functions/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>Handling TimeZones in CakePHP</title><link>http://trentrichardson.com/2010/03/05/handling-timezones-in-cakephp/</link> <comments>http://trentrichardson.com/2010/03/05/handling-timezones-in-cakephp/#comments</comments> <pubDate>Fri, 05 Mar 2010 13:15:02 +0000</pubDate> <dc:creator>trent</dc:creator> <category><![CDATA[CakePHP]]></category> <category><![CDATA[Database]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[Programming]]></category> <category><![CDATA[convert]]></category> <category><![CDATA[date]]></category> <category><![CDATA[datetime]]></category> <category><![CDATA[time]]></category> <category><![CDATA[timezone]]></category> <category><![CDATA[user]]></category><guid
isPermaLink="false">http://trentrichardson.com/?p=526</guid> <description><![CDATA[The web is a global resource for anything, anywhere, any timezone. But often times we are careless in consideration for people in other areas of the world. The different timezones offset people&#8217;s schedules from one area to the next. When handling user profiles (or anything for that matter) where date and time is involved we [...]
Related posts:<ol><li><a
href='http://trentrichardson.com/2009/03/31/handling-php-form-arrays-with-jquery/' rel='bookmark' title='Handling PHP Form Arrays with jQuery'>Handling PHP Form Arrays with jQuery</a></li><li><a
href='http://trentrichardson.com/2011/12/02/discussion-how-asynchronous-should-we-get/' rel='bookmark' title='Discussion &#8211; How Asynchronous Should We Get'>Discussion &#8211; How Asynchronous Should We Get</a></li><li><a
href='http://trentrichardson.com/2010/01/31/cakephp-postgresql-and-regex/' rel='bookmark' title='CakePHP, PostgreSQL, and Regex'>CakePHP, PostgreSQL, and Regex</a></li></ol>]]></description> <content:encoded><![CDATA[<p><img
src="http://trentrichardson.com/wp-content/uploads/2010/03/timezone.png" alt="Timezones with CakePHP" title="timezone" width="128" height="128" class="alignright size-full wp-image-530" /></p><p>The web is a global resource for anything, anywhere, any timezone.  But often times we are careless in consideration for people in other areas of the world.  The different timezones offset people&#8217;s schedules from one area to the next.  When handling user profiles (or anything for that matter) where date and time is involved we can do a little magic with our CakePHP app to make things a little more convenient for our users.  How do we handle this you ask?</p><p>First lets say when a user logs in to their profile they can click to edit the profile, selects his/her timezone, and clicks save. Relative to GMT we can calculate offsets of each timezone, where GMT would = 0.  So for instance Eastern Timezone for New York, US would be -5 since its 5 ours BEHIND GMT.  So lets start by generating a dropdown list with cake with all the different timezones, then save this list to the users profile.  If you are using Auth with CakePHP, you will likely have a users table, and we&#8217;ll add a decimal field called &#8220;timezone&#8221; to that table.  Fortunately there is a helper to assist us with this dropdown in the bakery, <a
href="http://bakery.cakephp.org/articles/view/updated-timezone-helper">Timezone Helper</a>.  By taking a look at the source you&#8217;ll notice all the labels associated with an offset &#8220;-5.0&#8243; or &#8220;+3.0&#8243;.  Also look a little closer and you might notice a few have actual decimal (Kabul is +4.5).  So first things first, go ahead and install that Helper as those instructions say.  Add it to your Edit view for users to edit their profile. Once included you just add the drop down to your form with:</p><pre><code class="php">
echo $timezone->select('timezone');
</code></pre><p>Now each user should have a timezone attached to their profile.  Now the trick to timezones is that no matter what the timezone of our server is, we just want to convert it to display to the user in that user&#8217;s preferred timezone.  On the reverse side, if a user enters a datetime, we convert it back to the timezone of the server.</p><p>Lets start our with the user viewing a date from the server, in our view we want to convert it to the user&#8217;s preferred timezone set to their profile (which should now be stored in their session, I&#8217;ll demonstrate with Auth)</p><pre><code class="php">
$time->format('F j, Y g:i:s a', $mydate, null, $session->read('Auth.User.timezone'));
</code></pre><p>Using the Time helper in CakePHP, the format function accepts a fourth parameter which indicates the timezone, which is extremely helpful.  So this is all you need to do to display a time from the server to a user.</p><p>Next lets say the user is about to edit a field from the server in a form.  First we need to select the existing data from the database, we&#8217;ll convert it to the user&#8217;s timezone, and place it in an input field to be edited.  Then once the user saves the data we&#8217;ll simply convert it back to the server&#8217;s timezone.  (There a bunch of &#8220;one liners&#8221; in doing all of these tasks).  So if you have your Time helper in your controller when you get the data from the database, go ahead and convert it to the new timezone just like we did before:</p><pre><code class="php">
$data['Model']['mydate'] = $time->format('Y-n-d H:i:sP', $data['Model']['mydate'], null, $this->Auth->user('timezone'));
</code></pre><p>Now in your view for the form there are a few different scenarios.  1) You use Cake&#8217;s default inputs for editing date times, with the 6 dropdowns, or 2) You use a plain input and use a date/time picker of some sort.  Lets first handle the first scenario, Cakes default 6 input datetime.  The data has been submitted, validated and we&#8217;re about to place it back in the database, we need to convert it back to server timezone.  But wait! the form field is broken down into an array of six elements: year, month, day, hour, minute, meridian.  Well we can create a nice little function that will convert this array into a datetime, and pass it our timezone:</p><pre><code class="php">
function dateTimeArrayToServerTZString($dt, $tz=0){
	$tz = (floatval($tz) >= 0)? '+'. number_format(floatval($tz),2,':','') : number_format(floatval($tz),2,':','');
	$dt['min'] = str_pad($dt['min'], 2, "0", STR_PAD_LEFT);

	$loc = $dt['year'] .'-'. $dt['month'] .'-'. $dt['day'] .' '. $dt['hour'] .':'. $dt['min'] .' '. $dt['meridian'] .' '. $tz;

	$datetime = new DateTime($loc);
	$datetime->setTimezone(new DateTimeZone(date('e', time())));

	return $datetime->format('Y-n-d H:i:sP');
}
</code></pre><p>Now right before I insert my data into the database I just need to call this function on that datetime array:</p><pre><code class="php">
$this->data['Model']['mydate'] = dateTimeArrayToServerTZString($this->data['Model']['mydate'], $this->Auth->user('timezone'));
</code></pre><p>Now $this->data['Model']['mydate'] will be a string, and cake still knows how to handle that just fine.  Now for the second scenerio, a user submitting a string.  This isn&#8217;t too hard at all, we just use our time helper and convert that puppy back to the server time.</p><pre><code class="php">
$this->data['Model']['mydate'] = $time->format('Y-n-d H:i:sP', $this->data['Model']['mydate'], null, -5);
</code></pre><p>Ok, so I&#8217;ve hardcoded in the timezone to -5 (Eastern Timezone), what if I want this to be dynamic to where ever my server is? Well the Time helper has a function which isn&#8217;t mentioned in the book called serverOffset(), which will return a number of the offset.  If you&#8217;re not using the helper and just want to get the timezone of the server its a simple one-liner:</p><pre><code class="php">
date('Z', time())
</code></pre><p>Thats all there is to handling timezones in your cakePHP site, or any site for that matter.  Just keep in mind as you go to convert any times for the user&#8217;s pleasure.  You have any tips or alternatives?</p><p>Related posts:<ol><li><a
href='http://trentrichardson.com/2009/03/31/handling-php-form-arrays-with-jquery/' rel='bookmark' title='Handling PHP Form Arrays with jQuery'>Handling PHP Form Arrays with jQuery</a></li><li><a
href='http://trentrichardson.com/2011/12/02/discussion-how-asynchronous-should-we-get/' rel='bookmark' title='Discussion &#8211; How Asynchronous Should We Get'>Discussion &#8211; How Asynchronous Should We Get</a></li><li><a
href='http://trentrichardson.com/2010/01/31/cakephp-postgresql-and-regex/' rel='bookmark' title='CakePHP, PostgreSQL, and Regex'>CakePHP, PostgreSQL, and Regex</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://trentrichardson.com/2010/03/05/handling-timezones-in-cakephp/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>Select Substring Using RegEx in PostgreSQL</title><link>http://trentrichardson.com/2010/02/24/select-substring-using-regex-in-postgresql/</link> <comments>http://trentrichardson.com/2010/02/24/select-substring-using-regex-in-postgresql/#comments</comments> <pubDate>Wed, 24 Feb 2010 13:06:24 +0000</pubDate> <dc:creator>trent</dc:creator> <category><![CDATA[Database]]></category><guid
isPermaLink="false">http://trentrichardson.com/?p=505</guid> <description><![CDATA[I thought of another handy scenario for using regular expressions in Postgres. This time not within the conditions, but in the returned results. Lets say for instance you have a column with URL, (maybe blog comments or something) and you would like to get a list of all the domain names, not the full paths [...]
Related posts:<ol><li><a
href='http://trentrichardson.com/2008/10/21/incorporating-regex-into-orms-and-database-abstractions/' rel='bookmark' title='Incorporating Regex into ORM&#8217;s and Database Abstractions'>Incorporating Regex into ORM&#8217;s and Database Abstractions</a></li><li><a
href='http://trentrichardson.com/2010/01/31/cakephp-postgresql-and-regex/' rel='bookmark' title='CakePHP, PostgreSQL, and Regex'>CakePHP, PostgreSQL, and Regex</a></li><li><a
href='http://trentrichardson.com/2010/02/03/adding-postgresql-regex-support-in-cakephp/' rel='bookmark' title='Adding PostgreSQL Regex Support in CakePHP'>Adding PostgreSQL Regex Support in CakePHP</a></li></ol>]]></description> <content:encoded><![CDATA[<p>I thought of another handy scenario for using regular expressions in Postgres.  This time not within the conditions, but in the returned results. Lets say for instance you have a column with URL, (maybe blog comments or something) and you would like to get a list of all the domain names, not the full paths trailing it nor the http://, how would you do that?  Without regular expressions you would be forced to use a combination of various string functions to look for the domain name, and you will also aquire a headache free of charge.  However with a simple regular expression you could do something like this:</p><pre><code class="mysql">
select SUBSTRING(url FROM 'http://([^/]*).*') as domainname from my table
</code></pre><p>Pretty simple you must admit.  Ok, so that is pretty straight forward.  Now lets say we wanted to scan a column for any phone numbers.  I&#8217;ll keep the phone number regular expression simple for this example.  The phone number is 10 numbers, with only a possible dash after the third and sixth numbers.</p><pre><code class="mysql">
select SUBSTRING(colname FROM '([0-9]{3}\-?[0-9]{3}\-?[0-9]{4})') as numstr from tablename
</code></pre><p>Ok, now one final scenario.  We are still looking for a phone number, but there could be more than one per column.  We would like to find them all!  Well, there&#8217;s a regex for that.</p><pre><code class="mysql">
select regexp_matches(colname, '([0-9]{3}\-?[0-9]{3}\-?[0-9]{4})', 'g') as numstr from tablename
</code></pre><p>Now you can see we&#8217;ve changed up our substring function to regexp_matches, which will give us the ability to search for all matches.  I&#8217;m sure most everyone is familar with a regular expression matching function so this is nothing new.  You can find more information on using these functions in the <a
href="http://www.postgresql.org/docs/current/static/functions-matching.html">Postgres Docs</a>.  Hope you&#8217;ve enjoyed more Regular Expressions with Postgres!</p><p>Related posts:<ol><li><a
href='http://trentrichardson.com/2008/10/21/incorporating-regex-into-orms-and-database-abstractions/' rel='bookmark' title='Incorporating Regex into ORM&#8217;s and Database Abstractions'>Incorporating Regex into ORM&#8217;s and Database Abstractions</a></li><li><a
href='http://trentrichardson.com/2010/01/31/cakephp-postgresql-and-regex/' rel='bookmark' title='CakePHP, PostgreSQL, and Regex'>CakePHP, PostgreSQL, and Regex</a></li><li><a
href='http://trentrichardson.com/2010/02/03/adding-postgresql-regex-support-in-cakephp/' rel='bookmark' title='Adding PostgreSQL Regex Support in CakePHP'>Adding PostgreSQL Regex Support in CakePHP</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://trentrichardson.com/2010/02/24/select-substring-using-regex-in-postgresql/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>CakePHP, PostgreSQL, and Regex</title><link>http://trentrichardson.com/2010/01/31/cakephp-postgresql-and-regex/</link> <comments>http://trentrichardson.com/2010/01/31/cakephp-postgresql-and-regex/#comments</comments> <pubDate>Mon, 01 Feb 2010 04:04:28 +0000</pubDate> <dc:creator>trent</dc:creator> <category><![CDATA[Database]]></category> <category><![CDATA[PHP]]></category><guid
isPermaLink="false">http://trentrichardson.com/?p=457</guid> <description><![CDATA[I was playing with cake and postgresql when I decided I needed to do a search. Sure a classic &#8216;%&#8217; search would have been sufficient, but we all know I love using regular expressions in sql. Well come to find out it doesn&#8217;t seem that CakePHP likes PostgreSQL&#8217;s syntax when using its native conditions, so [...]
Related posts:<ol><li><a
href='http://trentrichardson.com/2010/02/03/adding-postgresql-regex-support-in-cakephp/' rel='bookmark' title='Adding PostgreSQL Regex Support in CakePHP'>Adding PostgreSQL Regex Support in CakePHP</a></li><li><a
href='http://trentrichardson.com/2010/02/24/select-substring-using-regex-in-postgresql/' rel='bookmark' title='Select Substring Using RegEx in PostgreSQL'>Select Substring Using RegEx in PostgreSQL</a></li><li><a
href='http://trentrichardson.com/2008/05/22/jsonsql-ported-to-php/' rel='bookmark' title='JsonSQL Ported to PHP'>JsonSQL Ported to PHP</a></li></ol>]]></description> <content:encoded><![CDATA[<p>I was playing with cake and postgresql when I decided I needed to do a search.  Sure a classic &#8216;%&#8217; search would have been sufficient, but we all know I love using <a
href="http://trentrichardson.com/2008/10/23/exploring-various-sql-regex-syntax/">regular expressions in sql</a>.  Well come to find out it doesn&#8217;t seem that CakePHP likes PostgreSQL&#8217;s syntax when using its native conditions, so this didn&#8217;t work:</p><pre><code class="php">
'conditions'=>array(
	"Table.field ~*"=>$my_param
)
</code></pre><p>And neither did this:</p><pre><code class="php">
'conditions'=>array(
	"Table.field ~* ?"=>$my_param
)
</code></pre><p>I ended up having to create an array entry without a key at all, which is scary, but I knew for a fact that my sql parameter was only [a-zA-Z0-9].  Here&#8217;s what worked for me:</p><pre><code class="php">
'conditions'=>array(
	"Table.field ~* '$my_param'"
)
</code></pre><p>Bascially this told cake that this is the exact query condition I want to use without any parameters.  Take it and like it!  The docs read that it supports REGEX key word but we all know thats MySQL only (since you read my <a
href="http://trentrichardson.com/2008/10/23/exploring-various-sql-regex-syntax/">previous</a> <a
href="http://trentrichardson.com/2008/10/21/incorporating-regex-into-orms-and-database-abstractions/">posts</a>) :)</p><p>Related posts:<ol><li><a
href='http://trentrichardson.com/2010/02/03/adding-postgresql-regex-support-in-cakephp/' rel='bookmark' title='Adding PostgreSQL Regex Support in CakePHP'>Adding PostgreSQL Regex Support in CakePHP</a></li><li><a
href='http://trentrichardson.com/2010/02/24/select-substring-using-regex-in-postgresql/' rel='bookmark' title='Select Substring Using RegEx in PostgreSQL'>Select Substring Using RegEx in PostgreSQL</a></li><li><a
href='http://trentrichardson.com/2008/05/22/jsonsql-ported-to-php/' rel='bookmark' title='JsonSQL Ported to PHP'>JsonSQL Ported to PHP</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://trentrichardson.com/2010/01/31/cakephp-postgresql-and-regex/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>Connect to SQL Server from Ubuntu: Part II</title><link>http://trentrichardson.com/2010/01/11/connect-to-sql-server-from-ubuntu-part-ii/</link> <comments>http://trentrichardson.com/2010/01/11/connect-to-sql-server-from-ubuntu-part-ii/#comments</comments> <pubDate>Mon, 11 Jan 2010 12:34:20 +0000</pubDate> <dc:creator>trent</dc:creator> <category><![CDATA[Database]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[Programming]]></category><guid
isPermaLink="false">http://trentrichardson.com/?p=446</guid> <description><![CDATA[A few posts ago I explained how you can connect Ubuntu to SQL Server for PHP. All worked well until you tried to execute stored procedures. (It worked fine if you wrote the query, but not so much with mssql_execute() function). It would result in an error like this: Warning: mssql_execute() [function.mssql-execute]: stored procedure execution [...]
Related posts:<ol><li><a
href='http://trentrichardson.com/2009/12/09/connect-to-sql-server-from-ubuntu/' rel='bookmark' title='Connect to SQL Server from Ubuntu'>Connect to SQL Server from Ubuntu</a></li><li><a
href='http://trentrichardson.com/2008/04/21/localhost-subdomains-on-ubuntu/' rel='bookmark' title='Localhost Subdomains on Ubuntu'>Localhost Subdomains on Ubuntu</a></li><li><a
href='http://trentrichardson.com/2008/11/12/intrepid-ibex-and-apache2-virtualhosts/' rel='bookmark' title='Intrepid Ibex and Apache2 VirtualHost'>Intrepid Ibex and Apache2 VirtualHost</a></li></ol>]]></description> <content:encoded><![CDATA[<p>A few posts ago I explained how you can <a
href="http://trentrichardson.com/2009/12/09/connect-to-sql-server-from-ubuntu/">connect Ubuntu to SQL Server for PHP</a>.  All worked well until you tried to execute stored procedures.  (It worked fine if you wrote the query, but not so much with mssql_execute() function).  It would result in an error like this:</p><p>Warning: mssql_execute() [function.mssql-execute]: stored procedure execution failed</p><p>Well I did a little searching around and found out it <a
href="http://docs.moodle.org/en/Installing_MSSQL_for_PHP">appears to be a freetds issue</a>, where you need to alter the freetds.conf file.  This article tells you the correct config (tds version = 8.0 is the secret I believe), however it tells you the wrong location of freetds.conf for Ubuntu.  Within Ubuntu you will find this file in /etc/freetds/freetds.conf.  You will need to add the following (with your host and port of course):</p><pre><code class="js">
host = xxx.xxx.xxx.xxx
port = 1433
tds version = 8.0
</code></pre><p>In my file I already had a [global] section and I just added it into there.  After saving these settings into that file I was then able to call my stored procedures with no problem!</p><p>Related posts:<ol><li><a
href='http://trentrichardson.com/2009/12/09/connect-to-sql-server-from-ubuntu/' rel='bookmark' title='Connect to SQL Server from Ubuntu'>Connect to SQL Server from Ubuntu</a></li><li><a
href='http://trentrichardson.com/2008/04/21/localhost-subdomains-on-ubuntu/' rel='bookmark' title='Localhost Subdomains on Ubuntu'>Localhost Subdomains on Ubuntu</a></li><li><a
href='http://trentrichardson.com/2008/11/12/intrepid-ibex-and-apache2-virtualhosts/' rel='bookmark' title='Intrepid Ibex and Apache2 VirtualHost'>Intrepid Ibex and Apache2 VirtualHost</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://trentrichardson.com/2010/01/11/connect-to-sql-server-from-ubuntu-part-ii/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>Should ODBC Classes have a Syntax Layer?</title><link>http://trentrichardson.com/2009/12/28/should-odbc-classes-have-a-syntax-layer/</link> <comments>http://trentrichardson.com/2009/12/28/should-odbc-classes-have-a-syntax-layer/#comments</comments> <pubDate>Mon, 28 Dec 2009 12:29:32 +0000</pubDate> <dc:creator>trent</dc:creator> <category><![CDATA[Database]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[Programming]]></category><guid
isPermaLink="false">http://trentrichardson.com/?p=438</guid> <description><![CDATA[I don&#8217;t prefer using an ODBC datasource, but sometimes it is the easiest way to gain access to a database. Often times when using frameworks(php, not sure about others) an odbc option is available, however who knows if it will deliver sql compatible with the database we&#8217;re trying to gain access to. I&#8217;ll base this [...]
Related posts:<ol><li><a
href='http://trentrichardson.com/2008/10/23/exploring-various-sql-regex-syntax/' rel='bookmark' title='Exploring Various SQL RegEx Syntax'>Exploring Various SQL RegEx Syntax</a></li><li><a
href='http://trentrichardson.com/2010/01/31/cakephp-postgresql-and-regex/' rel='bookmark' title='CakePHP, PostgreSQL, and Regex'>CakePHP, PostgreSQL, and Regex</a></li><li><a
href='http://trentrichardson.com/2008/10/21/incorporating-regex-into-orms-and-database-abstractions/' rel='bookmark' title='Incorporating Regex into ORM&#8217;s and Database Abstractions'>Incorporating Regex into ORM&#8217;s and Database Abstractions</a></li></ol>]]></description> <content:encoded><![CDATA[<p>I don&#8217;t prefer using an ODBC datasource, but sometimes it is the easiest way to gain access to a database.  Often times when using frameworks(php, not sure about others) an odbc option is available, however who knows if it will deliver sql compatible with the database we&#8217;re trying to gain access to.  I&#8217;ll base this brainstorm on php, though it should relate across many different languages.</p><p><img
src="http://trentrichardson.com/wp-content/uploads/2009/12/orm_syntax_layer.jpg" alt="ORM Syntax Layer" title="ORM Syntax Layer" width="550" height="160" class="alignnone size-full wp-image-440" /></p><p>We all know that for the most part with a framework if you specify to use MySQL, or SQLite, or SQL Server it will generate the correct query to pull in your data.  But what happens when you&#8217;re using ODBC?  Most frameworks I&#8217;ve fiddled with(maybe some are different, I&#8217;d like to hear about their method or process) only allow you to specify ODBC, but not what database is being accessed, so how does it know how to build the query?  Should there be a syntax abstraction layer similar to the current database connection layer?  So maybe in database configs you might specify something like the following:</p><pre><code class="php">
$db_config = array(
	"type"=>"ODBC",
	"syntax"=>"mssql",
	"username"=>"myusername",
	"password"=>"password",
	"database"=>"somedb"
);
</code></pre><p>Same could be true for a PDO connection or ADO.  Of course if just a MySQL connection is specified it would know to pull the MySQL syntax class, but this becomes particularly useful in these situations.  Now this adds to the flexibility of many environments, as long as you have an ODBC connection you only need a general syntax file, mainly specifying specific differences in standard sql, like using LIMIT vs. TOP.  Or you could more easily implement <a
href="http://trentrichardson.com/2008/10/23/exploring-various-sql-regex-syntax/">regex within queries</a> like I&#8217;ve <a
href="http://trentrichardson.com/2008/10/21/incorporating-regex-into-orms-and-database-abstractions/">blogged about in the past</a>.</p><p>Related posts:<ol><li><a
href='http://trentrichardson.com/2008/10/23/exploring-various-sql-regex-syntax/' rel='bookmark' title='Exploring Various SQL RegEx Syntax'>Exploring Various SQL RegEx Syntax</a></li><li><a
href='http://trentrichardson.com/2010/01/31/cakephp-postgresql-and-regex/' rel='bookmark' title='CakePHP, PostgreSQL, and Regex'>CakePHP, PostgreSQL, and Regex</a></li><li><a
href='http://trentrichardson.com/2008/10/21/incorporating-regex-into-orms-and-database-abstractions/' rel='bookmark' title='Incorporating Regex into ORM&#8217;s and Database Abstractions'>Incorporating Regex into ORM&#8217;s and Database Abstractions</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://trentrichardson.com/2009/12/28/should-odbc-classes-have-a-syntax-layer/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>What Happens with MySQL? VirtualBox? Java?</title><link>http://trentrichardson.com/2009/04/21/what-happens-with-mysql-virtualbox-java/</link> <comments>http://trentrichardson.com/2009/04/21/what-happens-with-mysql-virtualbox-java/#comments</comments> <pubDate>Wed, 22 Apr 2009 01:18:28 +0000</pubDate> <dc:creator>trent</dc:creator> <category><![CDATA[Database]]></category> <category><![CDATA[Programming]]></category><guid
isPermaLink="false">http://trentrichardson.com/?p=331</guid> <description><![CDATA[As I&#8217;m sure everyone has heard Oracle has bought Sun Microsystems. As a linux user this could have a very big impact on my everyday computing. Sun produces atleast three products off the top of my head which I use every single day: MySQL, VirtualBox, and Java. There are probably others like Open Office, however [...]
Related posts:<ol><li><a
href='http://trentrichardson.com/2008/01/30/does-suns-deal-with-mysql-mean-a-move-to-postgresql/' rel='bookmark' title='Does Sun&#8217;s Deal with MySQL Mean a Move to PostgreSQL?'>Does Sun&#8217;s Deal with MySQL Mean a Move to PostgreSQL?</a></li><li><a
href='http://trentrichardson.com/2007/12/27/are-you-using-regular-expressions-within-sql/' rel='bookmark' title='Are You Using Regular Expressions Within SQL?'>Are You Using Regular Expressions Within SQL?</a></li><li><a
href='http://trentrichardson.com/2008/10/23/exploring-various-sql-regex-syntax/' rel='bookmark' title='Exploring Various SQL RegEx Syntax'>Exploring Various SQL RegEx Syntax</a></li></ol>]]></description> <content:encoded><![CDATA[<p>As I&#8217;m sure everyone has heard Oracle has bought Sun Microsystems.  As a linux user this could have a very big impact on my everyday computing.  Sun produces atleast three products off the top of my head which I use every single day: MySQL, VirtualBox, and Java.  There are probably others like Open Office, however I rarely use a word processor anymore.  MySQL is bringing up question from many people, as it is widely used and Oracle.. well Oracle is known for its database.  So what happens? Does Oracle leave Mysql alone?  Do they merge it in with their database?  Maybe they make extraordinary contributions to it.  Time only tells.</p><p>VirtualBox is another favorite of mine, and Java is used EVERYWHERE.  This could be as critical of time as ever in the programming/IT world.  Especially for companies who revolve around open source technologies.  So many websites are based on lamp.  I myself have been slowly trying to migrate towards PostgreSQL.  The buying and selling of MySQL has made me nervous lately.  What are your thoughts?</p><p>Related posts:<ol><li><a
href='http://trentrichardson.com/2008/01/30/does-suns-deal-with-mysql-mean-a-move-to-postgresql/' rel='bookmark' title='Does Sun&#8217;s Deal with MySQL Mean a Move to PostgreSQL?'>Does Sun&#8217;s Deal with MySQL Mean a Move to PostgreSQL?</a></li><li><a
href='http://trentrichardson.com/2007/12/27/are-you-using-regular-expressions-within-sql/' rel='bookmark' title='Are You Using Regular Expressions Within SQL?'>Are You Using Regular Expressions Within SQL?</a></li><li><a
href='http://trentrichardson.com/2008/10/23/exploring-various-sql-regex-syntax/' rel='bookmark' title='Exploring Various SQL RegEx Syntax'>Exploring Various SQL RegEx Syntax</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://trentrichardson.com/2009/04/21/what-happens-with-mysql-virtualbox-java/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>Exploring Various SQL RegEx Syntax</title><link>http://trentrichardson.com/2008/10/23/exploring-various-sql-regex-syntax/</link> <comments>http://trentrichardson.com/2008/10/23/exploring-various-sql-regex-syntax/#comments</comments> <pubDate>Thu, 23 Oct 2008 23:22:01 +0000</pubDate> <dc:creator>trent</dc:creator> <category><![CDATA[Database]]></category> <category><![CDATA[Programming]]></category><guid
isPermaLink="false">http://trentrichardson.com/?p=141</guid> <description><![CDATA[This is part two of my quest to Incorporating Regex into ORM&#8217;s and Database Abstractions. My first steps to exploring the option to implement uniform regex support into my own database orm/abstraction is to compare the syntax of the more popular database systems. To do so I will build an sql query where possible to [...]
Related posts:<ol><li><a
href='http://trentrichardson.com/2008/10/21/incorporating-regex-into-orms-and-database-abstractions/' rel='bookmark' title='Incorporating Regex into ORM&#8217;s and Database Abstractions'>Incorporating Regex into ORM&#8217;s and Database Abstractions</a></li><li><a
href='http://trentrichardson.com/2007/12/27/are-you-using-regular-expressions-within-sql/' rel='bookmark' title='Are You Using Regular Expressions Within SQL?'>Are You Using Regular Expressions Within SQL?</a></li><li><a
href='http://trentrichardson.com/2009/12/28/should-odbc-classes-have-a-syntax-layer/' rel='bookmark' title='Should ODBC Classes have a Syntax Layer?'>Should ODBC Classes have a Syntax Layer?</a></li></ol>]]></description> <content:encoded><![CDATA[<p>This is part two of my quest to <a
href="http://trentrichardson.com/2008/10/21/incorporating-regex-into-orms-and-database-abstractions/">Incorporating Regex into ORM&#8217;s and Database Abstractions</a>.  My first steps to exploring the option to implement uniform regex support into my own database orm/abstraction is to compare the syntax of the more popular database systems.  To do so I will build an sql query where possible to search the body of page contents for &#8216;bla bla bla..&#8217; in a test database table.</p><p><strong>MySQL</strong></p><p><code
class="mysql"><br
/> select * from pages where body REGEXP '(bla(\s)?)+'<br
/> </code></p><p><strong>Postgres</strong></p><p><code
class="mysql"><br
/> select * from pages where body ~ '(bla(\s)?)+'<br
/> </code></p><p><strong>SQL Server</strong></p><p>SQL Server doesn&#8217;t appear to natively support regex without the <a
href="http://anastasiosyal.com/archive/2008/07/05/regular-expressions-in-ms-sql-server-using-clr.aspx">help of CLR</a>.</p><p><code
class="mysql"><br
/> select * from pages where dbo.RegExMatch( body,'(bla(\s)?)+')<br
/> </code></p><p><strong>SQLite</strong></p><p>SQLite similarly does not natively support Regular Expressions, however <a
href="http://www.sqlite.org/lang_expr.html">SQLite can be extended</a> as well to do so:</p><blockquote><p>The REGEXP operator is a special syntax for the regexp() user function. No regexp() user function is defined by default and so use of the REGEXP operator will normally result in an error message. If a user-defined function named &#8220;regexp&#8221; is added at run-time, that function will be called in order to implement the REGEXP operator.</p></blockquote><p>So SQLite recognizes REGEXP, but it is not implemented.  It states that if we implement regexp() it can use it.  So here might be the way to implement <a
href="http://lv2.php.net/manual/en/function.sqlite-create-function.php">REGEXP using PHP</a>.  Implementing this should result in a syntax similar to MySQL&#8217;s syntax.</p><p><strong>DB2</strong></p><p>DB2 falls into the same category as SQL Server and SQLite by needing to create a function to implement Regular Expressions.  Implementing <a
href="http://www-128.ibm.com/developerworks/db2/library/techarticle/0301stolze/0301stolze.html">this function</a> can be done in C and appears to support pretty standard RegEx syntax.</p><p><strong>Oracle</strong></p><p>Oracle Database does reportedly support Regular Expressions.  While I do not have an Oracle database to test on, it is <a
href="http://www.oracle.com/technology/oramag/webcolumns/2003/techarticles/rischert_regexp_pt1.html">reported</a> to work like the following:</p><p><code
class="mysql"><br
/> SELECT zip FROM zipcode WHERE REGEXP_LIKE(zip, '[^[:digit:]]')<br
/> </code></p><p><strong>Informix</strong></p><p>Informix seems to <a
href="http://www.ibm.com/developerworks/db2/zones/informix/library/techarticle/db_regexp.html">support regular expressions</a>, however it does require that you have regexp1.0 installed to use them.  Using this feature consists of calling a function rather than using an operator.</p><p><strong>Sybase</strong></p><p>I could not find any definite resources to indicate whether Sybase supports regular expressions or not.  Perhaps if someone is familiar with this database they could shed some light on this.</p><p>After examining the different database engines a little more closely and their capabilities of handling Regular Expressions, I have found that support is surprisingly not very good from proprietary databases, however there are ways to implement it in most systems.  However MySQL, Postgres, and Oracle(the exception to the proprietary databases) appear to support regex straight out of the box.  This is a little discouraging, however if you could supply the necessary tools, libraries, functions, or procedures to enable regular expressions it would still be possible.</p><p>Related posts:<ol><li><a
href='http://trentrichardson.com/2008/10/21/incorporating-regex-into-orms-and-database-abstractions/' rel='bookmark' title='Incorporating Regex into ORM&#8217;s and Database Abstractions'>Incorporating Regex into ORM&#8217;s and Database Abstractions</a></li><li><a
href='http://trentrichardson.com/2007/12/27/are-you-using-regular-expressions-within-sql/' rel='bookmark' title='Are You Using Regular Expressions Within SQL?'>Are You Using Regular Expressions Within SQL?</a></li><li><a
href='http://trentrichardson.com/2009/12/28/should-odbc-classes-have-a-syntax-layer/' rel='bookmark' title='Should ODBC Classes have a Syntax Layer?'>Should ODBC Classes have a Syntax Layer?</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://trentrichardson.com/2008/10/23/exploring-various-sql-regex-syntax/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>Incorporating Regex into ORM&#8217;s and Database Abstractions</title><link>http://trentrichardson.com/2008/10/21/incorporating-regex-into-orms-and-database-abstractions/</link> <comments>http://trentrichardson.com/2008/10/21/incorporating-regex-into-orms-and-database-abstractions/#comments</comments> <pubDate>Wed, 22 Oct 2008 01:01:19 +0000</pubDate> <dc:creator>trent</dc:creator> <category><![CDATA[Database]]></category> <category><![CDATA[JsonSQL]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[Programming]]></category> <category><![CDATA[orm]]></category> <category><![CDATA[regex]]></category> <category><![CDATA[regular expressions]]></category><guid
isPermaLink="false">http://trentrichardson.com/?p=139</guid> <description><![CDATA[Almost on a daily basis I come across using regular expressions rather convenient. I first toyed with regular expressions in my Compiler Design classes during my undergrad studies, and little did I know they can be used for everyday things like submitting forms. I&#8217;ve even toyed with them to create my own json parser using [...]
Related posts:<ol><li><a
href='http://trentrichardson.com/2008/10/23/exploring-various-sql-regex-syntax/' rel='bookmark' title='Exploring Various SQL RegEx Syntax'>Exploring Various SQL RegEx Syntax</a></li><li><a
href='http://trentrichardson.com/2010/02/24/select-substring-using-regex-in-postgresql/' rel='bookmark' title='Select Substring Using RegEx in PostgreSQL'>Select Substring Using RegEx in PostgreSQL</a></li><li><a
href='http://trentrichardson.com/2010/01/31/cakephp-postgresql-and-regex/' rel='bookmark' title='CakePHP, PostgreSQL, and Regex'>CakePHP, PostgreSQL, and Regex</a></li></ol>]]></description> <content:encoded><![CDATA[<p><img
src="http://trentrichardson.com/wp-content/uploads/2008/10/regexp_orm-300x60.jpg" alt="" title="Regexp + ORM" width="300" height="60" align="right" class="alignright size-medium wp-image-140" /><p>Almost on a daily basis I come across using regular expressions rather convenient.  I first toyed with regular expressions in my Compiler Design classes during my undergrad studies, and little did I know they can be used for everyday things like submitting forms.  I&#8217;ve even toyed with them to create my own <a
href="http://trentrichardson.com/jsonsql/">json parser using an SQL like syntax</a>.  I think they&#8217;re a great way to perform strict validation and searching among other things.  Searching.  There is something I need to work on.  Not just strings, but database searches for account numbers, phone numbers, etc.  Not just &#8216;%some string%&#8217;. <a
href="http://trentrichardson.com/2007/12/27/are-you-using-regular-expressions-within-sql/">Regular Expressions within SQL</a> is something I have blogged about before.  I&#8217;ve come to find that Regular Expression support is far from constant and in some cases not even supported(SQLite).</p><p>Incase you&#8217;re curious what I&#8217;m talking about, some database engines allow you to write something like the following:</p><p><code
class="mysql"><br
/> SELECT zip FROM zipcode WHERE REGEXP_LIKE(zip, '[^[:digit:]]’)<br
/> </code></p><p>Sure, this process probably isn&#8217;t very efficient, but it can be very powerful.</p><p>More and more frameworks are moving towards ORM&#8217;s.  You no longer have to write database specific code as the database layer will handle the specifics for you, but none that I am aware of will handle anything of this complexity and for obvious reason.  Lets step back to a simpler solution that many of us deal with on a daily basis:</p><p><code
class="javascript"><br
/> $("input[name$='letter']")<br
/> </code></p><p>jQuery somewhat creates it&#8217;s own language.  It&#8217;s not xpath, its somewhat CSS selectors(ok, mostly css selectors), but there&#8217;s much more added to it&#8217;s own engine.  Perhaps this approach could be a simple solution to the problem.  Support a simplified subset or maybe my own mini language, and use the driver specific code to handle generating the database specific Regular Expressions.  Here&#8217;s what such example may resemble in pseudo code:</p><p><code
class="php"><br
/> $db->select('mytable')->where_regex("acct", "^\d{4}\-\d{8}$");<br
/> </code></p><p>This code might search mytable for the acct that matches a pattern like &#8220;1234-12345678&#8243;.  This isn&#8217;t terribly complex, however will suffice for the majority of everyday needs.  Only supporting this level of complexity is more within the reach creating such if possible.  This is my first post among others to come as this is mostly a brainstorm at this point.  I openly welcome any pointers, advice, resources, or any other comments!</p><p>Related posts:<ol><li><a
href='http://trentrichardson.com/2008/10/23/exploring-various-sql-regex-syntax/' rel='bookmark' title='Exploring Various SQL RegEx Syntax'>Exploring Various SQL RegEx Syntax</a></li><li><a
href='http://trentrichardson.com/2010/02/24/select-substring-using-regex-in-postgresql/' rel='bookmark' title='Select Substring Using RegEx in PostgreSQL'>Select Substring Using RegEx in PostgreSQL</a></li><li><a
href='http://trentrichardson.com/2010/01/31/cakephp-postgresql-and-regex/' rel='bookmark' title='CakePHP, PostgreSQL, and Regex'>CakePHP, PostgreSQL, and Regex</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://trentrichardson.com/2008/10/21/incorporating-regex-into-orms-and-database-abstractions/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Navicat For Postgres on Ubuntu</title><link>http://trentrichardson.com/2008/04/18/navicat-for-postgres-on-ubuntu/</link> <comments>http://trentrichardson.com/2008/04/18/navicat-for-postgres-on-ubuntu/#comments</comments> <pubDate>Fri, 18 Apr 2008 17:00:02 +0000</pubDate> <dc:creator>trent</dc:creator> <category><![CDATA[Database]]></category> <category><![CDATA[Linux]]></category><guid
isPermaLink="false">http://trentrichardson.com/?p=80</guid> <description><![CDATA[I ran across Navicat&#8217;s Postgres Administration tool the other day and just out of curiosity I decided to install it on Ubuntu (the lite version). Uhho, there&#8217;s no linux version! Well as any linux fanatic would do I grabbed the Windows version and tried to install with Wine, and well,.. it worked. After clicking around [...]
Related posts:<ol><li><a
href='http://trentrichardson.com/2008/01/20/sqlite-administration-on-ubuntu/' rel='bookmark' title='SQLite Administration on Ubuntu'>SQLite Administration on Ubuntu</a></li><li><a
href='http://trentrichardson.com/2009/09/01/fancy-new-opera-10-in-ubuntu/' rel='bookmark' title='Fancy New Opera 10 in Ubuntu'>Fancy New Opera 10 in Ubuntu</a></li><li><a
href='http://trentrichardson.com/2007/10/29/ubuntu-710-64-bit-a-bad-idea/' rel='bookmark' title='Ubuntu 7.10 64 bit A Bad Idea?'>Ubuntu 7.10 64 bit A Bad Idea?</a></li></ol>]]></description> <content:encoded><![CDATA[<p><img
width="250" height="188" align="right" alt="Navicat Postgres" id="image79" title="Navicat Postgres" src="http://trentrichardson.com/wp-content/uploads/2008/04/navicat_postgresql.png" />I ran across <a
target="_blank" title="Navicat Postgres" href="http://pgsql.navicat.com/detail.html">Navicat&#8217;s Postgres</a> Administration tool the other day and just out of curiosity I decided to install it on Ubuntu (the lite version).  Uhho, there&#8217;s no linux version!  Well as any linux fanatic would do I grabbed the Windows version and tried to install with Wine, and well,.. it worked.  After clicking around a bit I don&#8217;t foresee myself switching from <a
title="pgAdmin III" target="_blank" href="http://www.pgadmin.org/">pgAdmin</a>(it actually looks a lot like pgAdmin III), but it does have a few pro&#8217;s and con&#8217;s.  They also have a MySQL counterpart, but there is a linux version available for it.</p><p>Of all the database admin tools I&#8217;ve used however I&#8217;ve found none as nice as.. yes, I&#8217;m going to say it.. Microsoft&#8217;s SQL Server Management Studio.  I think the biggest thing Management Studio has going for it is the very clean interface, and the fact that every button doesn&#8217;t pop open a new window and it&#8217;s a one stop shop for user administrator as well as data manager.  MySQL has the two separate applications, other than that I love their query browser as well.  Are there any other great database admin tools out there that are reasonably price??</p><p>Related posts:<ol><li><a
href='http://trentrichardson.com/2008/01/20/sqlite-administration-on-ubuntu/' rel='bookmark' title='SQLite Administration on Ubuntu'>SQLite Administration on Ubuntu</a></li><li><a
href='http://trentrichardson.com/2009/09/01/fancy-new-opera-10-in-ubuntu/' rel='bookmark' title='Fancy New Opera 10 in Ubuntu'>Fancy New Opera 10 in Ubuntu</a></li><li><a
href='http://trentrichardson.com/2007/10/29/ubuntu-710-64-bit-a-bad-idea/' rel='bookmark' title='Ubuntu 7.10 64 bit A Bad Idea?'>Ubuntu 7.10 64 bit A Bad Idea?</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://trentrichardson.com/2008/04/18/navicat-for-postgres-on-ubuntu/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Database Caching 2/112 queries in 0.082 seconds using disk: basic
Object Caching 2756/2860 objects using disk: basic

Served from: trentrichardson.com @ 2012-02-03 21:29:34 -->
