<?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>www.pokeroconnor.com &#187; MySQL</title>
	<atom:link href="http://www.pokeroconnor.com/category/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.pokeroconnor.com</link>
	<description></description>
	<lastBuildDate>Fri, 19 Aug 2011 18:59:17 +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>phpmyadmin cant create database error</title>
		<link>http://www.pokeroconnor.com/phpmyadmin-cant-create-database-error/</link>
		<comments>http://www.pokeroconnor.com/phpmyadmin-cant-create-database-error/#comments</comments>
		<pubDate>Tue, 02 Nov 2010 23:02:57 +0000</pubDate>
		<dc:creator>PokerOConnor</dc:creator>
				<category><![CDATA[Linux/Unix/OSX/Apache]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.pokeroconnor.com/?p=327</guid>
		<description><![CDATA[If you&#8217;re getting the following error in phpmyadmin when creating a new database: #1006 &#8211; Can&#8217;t create database The problem is that /var/lib/mysql is probably owned by root, and ALSO in the root group. It should not be. ls -ld /var/lib/mysql probably looks like this: drwxrwxr-x 4 root root 4096 2010-11-01 23:45 /var/lib/mysql It should [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re getting the following error in phpmyadmin when creating a new database:</p>
<p><em><strong>#1006 &#8211; Can&#8217;t create database</strong></em></p>
<p>The problem is that /var/lib/mysql is probably owned by root, and ALSO in the root group. It should not be.</p>
<p>ls -ld /var/lib/mysql probably looks like this:</p>
<p>drwxrwxr-x 4 root root 4096 2010-11-01 23:45 /var/lib/mysql</p>
<p>It should be:</p>
<p>drwxrwxr-x 4 root mysql 4096 2010-11-01 23:45 /var/lib/mysql</p>
<p>So, run</p>
<p>chgrp -R mysql /var/lib/mysql</p>
<p>and you should be able to create databases now.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pokeroconnor.com/phpmyadmin-cant-create-database-error/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>phpmyadmin debian password protect</title>
		<link>http://www.pokeroconnor.com/phpmyadmin-debian-password-protect/</link>
		<comments>http://www.pokeroconnor.com/phpmyadmin-debian-password-protect/#comments</comments>
		<pubDate>Mon, 01 Nov 2010 23:22:31 +0000</pubDate>
		<dc:creator>PokerOConnor</dc:creator>
				<category><![CDATA[Linux/Unix/OSX/Apache]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.pokeroconnor.com/?p=321</guid>
		<description><![CDATA[Quick one &#8211; steps to password protect your phpmyadmin on Debian. Good idea also to use a symlink to obfuscate the &#8216;phpmyadmin&#8217; url too. Eg. within the docroot of a site I wish to install phpmyadmin on, I would do: cd /var/www/site ln -s SECRET_PATH_TO_DB /usr/share/phpmyadmin/ Your phpmyadmin install is then available on site.com/SECRET_PATH_TO_DB For [...]]]></description>
			<content:encoded><![CDATA[<p>Quick one &#8211; steps to<a href="http://www.halecomm.net/blog/2010/03/htpasswd-protecting-your-phpmyadmin-installation-debian/"> password protect your phpmyadmin on Debian</a>.</p>
<p>Good idea also to use a symlink to obfuscate the &#8216;phpmyadmin&#8217; url too.</p>
<p>Eg. within the docroot of a site I wish to install phpmyadmin on, I would do:</p>
<p>cd /var/www/site</p>
<p>ln -s SECRET_PATH_TO_DB /usr/share/phpmyadmin/</p>
<p>Your phpmyadmin install is then available on site.com/SECRET_PATH_TO_DB</p>
<p>For the htaccess password protection, this is a<a href="http://www.htaccesstools.com/htpasswd-generator/"> very handy generator tool.</a> The username and password you choose for the .htpasswd protection should be saved to <strong>/usr/share/phpmyadmin/.htpasswd</strong> (swap /usr/share for whatever install path you have).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pokeroconnor.com/phpmyadmin-debian-password-protect/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>mysql cannot login with root user</title>
		<link>http://www.pokeroconnor.com/mysql-cannot-login-with-root-user/</link>
		<comments>http://www.pokeroconnor.com/mysql-cannot-login-with-root-user/#comments</comments>
		<pubDate>Mon, 01 Nov 2010 22:57:17 +0000</pubDate>
		<dc:creator>PokerOConnor</dc:creator>
				<category><![CDATA[hosting]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.pokeroconnor.com/?p=316</guid>
		<description><![CDATA[If you ever come across the issue where your &#8216;root&#8217; user cannot login to mysql on debian, here&#8217;s a neat solution that will save you having to re-install mysql. mysql -u root ERROR 1045 (28000): Access denied for user &#8216;root&#8217;@'localhost&#8217; (using password: NO) Then you try: mysql -u root -pxxxxx ERROR 1045 (28000): Access denied [...]]]></description>
			<content:encoded><![CDATA[<p>If you ever come across the issue where your &#8216;root&#8217; user cannot login to mysql on debian, here&#8217;s a neat solution that will save you having to re-install mysql.<br />
<code><br />
mysql -u root</code></p>
<p>ERROR 1045 (28000): Access denied for user &#8216;root&#8217;@'localhost&#8217; (using password: NO)</p>
<p>Then you try:<br />
<code><br />
mysql -u root -pxxxxx</code></p>
<p>ERROR 1045 (28000): Access denied for user &#8216;root&#8217;@'localhost&#8217; (using password: YES)</p>
<p>I don&#8217;t know how this happened, but <a href="http://ubuntuforums.org/archive/index.php/t-27156.html">on Debian what you can do is</a>:</p>
<p>Go to your /etc/mysql/debian.cnf file, and copy the password for the debian-sys-maint mysql user.</p>
<p>Typically will look like:</p>
<p>host     = localhost<br />
user     = debian-sys-maint<br />
password = 123456789</p>
<p>Login to mysql as debian-sys-maint:</p>
<p>mysql -u debian-sys-maint -p123456789</p>
<p>Then, switch to mysql database,</p>
<p>use mysql;</p>
<p>Now check your root user is still there, on localhost. If so, just set a new password, i.e.</p>
<p>SET PASSWORD FOR &#8216;root&#8217;@'localhost&#8217; = PASSWORD(&#8216;password-value&#8217;);</p>
<p>Note, it <a href="http://www.howtoforge.com/forums/showthread.php?t=24394">will not work</a> if you just do</p>
<p>SET PASSWORD FOR &#8216;root&#8217; = PASSWORD(&#8216;password-value&#8217;);</p>
<p>That&#8217;s it, exit, restart mysql and you should be able to log with root again!</p>
<p>Of course if root user doesn&#8217;t exist anymore in the user table on mysql, just recreate and ensure you grant all privileges.</p>
<p>One final thing &#8211; if you use phpmyadmin, you will need to change the password for root in /etc/phpmyadmin/config.inc.php to match your new one.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pokeroconnor.com/mysql-cannot-login-with-root-user/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>xampp setup for mac</title>
		<link>http://www.pokeroconnor.com/xampp-setup-for-mac/</link>
		<comments>http://www.pokeroconnor.com/xampp-setup-for-mac/#comments</comments>
		<pubDate>Wed, 15 Sep 2010 22:06:33 +0000</pubDate>
		<dc:creator>PokerOConnor</dc:creator>
				<category><![CDATA[Linux/Unix/OSX/Apache]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.pokeroconnor.com/?p=312</guid>
		<description><![CDATA[For local development I use Xampp, which I find to be very handy. It&#8217;s really simple to and quick to setup, but there were just 2 gripes I had when setting it up that took an hour or so to fix &#8211; very annoying, so just recording them here for reference. Firstly, the install is [...]]]></description>
			<content:encoded><![CDATA[<p>For local development I use <a href="http://www.apachefriends.org/en/xampp-macosx.html">Xampp</a>, which I find to be very handy. It&#8217;s really simple to and quick to setup, but there were just 2 gripes I had when setting it up that took an hour or so to fix &#8211; very annoying, so just recording them here for reference.</p>
<p>Firstly, the install is as easy as detailed on the <a href="http://www.apachefriends.org/en/xampp-macosx.html">official page</a>, and the best guide I found was <a href="http://www.acwolf.com/2009/02/24/xampp-virtual-hosts-on-a-mac/">this excellent one</a>.</p>
<p>There are a tonne of files in your /Applications/XAMPP folder, but the most usual thing is to setup a Vhost. Edit the /Applications/XAMPP/etc/extra/httpd-vhosts.conf file for that.</p>
<p><strong>BUT</strong>, the first catch is you need to ensure that the following line is <strong>uncommented</strong> in the /Applications/XAMPP/etc/httpd.conf file:</p>
<p><em> Include etc/extra/httpd-xampp.conf</em></p>
<p>Gaaahhh!!!</p>
<p>Second gripe, your htaccess or <a href="http://www.talkphp.com/general/4774-mod_rewrite-not-working.html">mod_rewrite won&#8217;t work probably</a>, so you need to make sure that<em><strong> AllowOverride None </strong></em>is changed to <em><strong>AllowOverride All </strong></em>in /Applications/XAMPP/etc/httpd.conf, e.g.</p>
<p><em>&lt;Directory /&gt;<br />
Options FollowSymLinks<br />
AllowOverride All</em></p>
<p>Apart from those two minor annoyances, it was plain sailing!</p>
<p><em><br />
</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.pokeroconnor.com/xampp-setup-for-mac/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zend Form Password</title>
		<link>http://www.pokeroconnor.com/zend-form-password/</link>
		<comments>http://www.pokeroconnor.com/zend-form-password/#comments</comments>
		<pubDate>Sat, 16 May 2009 23:17:09 +0000</pubDate>
		<dc:creator>PokerOConnor</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.pokeroconnor.com/?p=248</guid>
		<description><![CDATA[When using Zend Form, and you have a password field and confirm password field, it is very handy to use Validation Context. It is described in the Zend documentation, just search for &#8220;My_Validate_PasswordConfirmation&#8221;. As is typical in Zend docs, the example is shit, they just give a class definition. So, here&#8217;s a brief example of I [...]]]></description>
			<content:encoded><![CDATA[<p>When using Zend Form, and you have a password field and confirm password field, it is very handy to use <em>Validation Context</em>. It is described in the <a href="http://framework.zend.com/manual/en/zend.form.elements.html">Zend documentation</a>, just search for &#8220;My_Validate_PasswordConfirmation&#8221;. As is typical in Zend docs, the example is shit, they just give a class definition. So, here&#8217;s a brief example of I used it.</p>
<p>Basically what you need to do is attach the validator to both the password <em><strong>and</strong></em> the confirm password field. </p>
<p>So firstly, add the class:<br />
<code><br />
class My_Validate_PasswordConfirmation extends Zend_Validate_Abstract<br />
{<br />
const NOT_MATCH = 'notMatch';</code></p>
<p><code>protected $_messageTemplates = array(<br />
self::NOT_MATCH =&gt; 'Password confirmation does not match'<br />
);</code></p>
<p><code>public function isValid($value, $context = null)<br />
{<br />
$value = (string) $value;<br />
$this-&gt;_setValue($value);</code></p>
<p><code>if (is_array($context)) {<br />
if (isset($context['password_confirm'])<br />
&amp;&amp; ($value == $context['password_confirm']))<br />
{<br />
return true;<br />
}<br />
} elseif (is_string($context) &amp;&amp; ($value == $context)) {<br />
return true;<br />
}</p>
<p></code></p>
<p> </p>
<p> </p>
<p><code> $this-&gt;_error(self::NOT_MATCH);<br />
return false;<br />
}<br />
}</code></p>
<p>Then, in your form file, use it something like follows:<br />
<code><br />
class RegisterForm extends Zend_Dojo_Form</code></p>
<p><code>{</code></p>
<p><code>public function init()</code></p>
<p><code>{<br />
$form = new Zend_Form();<br />
....<br />
....<br />
....<br />
$custom_pass = new MyValidatePasswordConfirmation();</p>
<p>...<br />
...<br />
$password = $form-&gt;createElement('password', 'password')<br />
-&gt;addValidator('StringLength', false, array(1,24))<br />
-&gt;setLabel('Choose your password:')<br />
-&gt;addValidator('Alnum')<br />
-&gt;addValidator($custom_pass)<br />
-&gt;setRequired(true);</p>
<p></code></p>
<p> </p>
<p> </p>
<p><code> $password_confirm = $form-&gt;createElement('password', 'password_confirm')<br />
-&gt;addValidator('StringLength', false, array(1,24))<br />
-&gt;setLabel('Confirm your password:')<br />
-&gt;addValidator('Alnum')<br />
-&gt;addValidator($custom_pass)<br />
-&gt;setRequired(true);<br />
</code></p>
<p>It&#8217;s fairly straightforward, but of course there&#8217;s very few examples I could find, this is <a href="http://www.zfforums.com/zend-framework-general-discussions-1/general-q-zend-framework-2/need-help-zend_form-723.html">probably the best</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pokeroconnor.com/zend-form-password/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Free SMS Gateways</title>
		<link>http://www.pokeroconnor.com/free-sms-gateways/</link>
		<comments>http://www.pokeroconnor.com/free-sms-gateways/#comments</comments>
		<pubDate>Mon, 27 Apr 2009 21:54:57 +0000</pubDate>
		<dc:creator>PokerOConnor</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.pokeroconnor.com/?p=212</guid>
		<description><![CDATA[Will fill in more info later, but here&#8217;s the basics so far: got this amazing free sms Gateway, playSMS. Great install instructions, such as: playSMS Web Interface: 1.  It is important to meet all minimum requiments above 2.  Setup a system user named &#8216;playsms&#8217; to manage playSMS     # adduser playsms     # passwd playsms [...]]]></description>
			<content:encoded><![CDATA[<p>Will fill in more info later, but here&#8217;s the basics so far: got this amazing free sms Gateway, <a href="http://playsms.sourceforge.net/">playSMS</a>. Great install instructions, such as:</p>
<p>playSMS Web Interface:</p>
<p>1.  It is important to meet all minimum requiments above</p>
<p>2.  Setup a system user named &#8216;playsms&#8217; to manage playSMS</p>
<p>    # adduser playsms</p>
<p>    # passwd playsms</p>
<p>    Note: on some Linux distributions adduser and passwd combined (Debian, Ubuntu and maybe others)</p>
<p>3.  On most Linux distributions actions (2) will create system user and group named &#8216;playsms&#8217;</p>
<p>    with home directory /home/playsms, but you will install playSMS in different directory</p>
<p>4.  Create playSMS web root, spool and log and set ownership to user www-data or web server user</p>
<p>    # mkdir -p /var/www/playsms</p>
<p>    # mkdir -p /var/spool/playsms</p>
<p>    # mkdir -p /var/log/playsms</p>
<p>    # chown -R www-data /var/www/playsms</p>
<p>    # chown -R www-data /var/spool/playsms</p>
<p>    # chown -R www-data /var/log/playsms</p>
<p>5.  Extract playSMS package somewhere (Usually in /usr/local/src)</p>
<p>    # tar -zxvf playsms-x.x.x.tar.gz -C /usr/local/src</p>
<p>    Note: x.x.x may vary according to the package name you&#8217;ve download</p>
<p>6.  Copy files and directories inside &#8216;web&#8217; directory to playSMS web root and set ownership again to </p>
<p>    user www-data or apache web server user</p>
<p>    # cd /usr/local/src/playsms-x.x.x/web</p>
<p>    # cp -rR * /var/www/playsms</p>
<p>    # chown -R www-data /var/www/playsms</p>
<p>    Note: assumed your web server user is www-data</p>
<p>7.  Setup database (import database)</p>
<p>    # mysqladmin -u root -p create playsms</p>
<p>    # mysql -u root -p playsms &lt; /usr/local/src/playsms-x.x.x/db/playsms.sql</p>
<p>    Note: you dont need to use MySQL root access nor this method to setup playSMS</p>
<p>    database, but this is beyond our scope, you should read MySQL manual&#8217;s for custom</p>
<p>    installation method or howto insert SQL statements into existing database</p>
<p>8.  Copy config-dist.php to config.php and edit config.php</p>
<p>    # cd /var/www/playsms</p>
<p>    # cp config-dist.php config.php</p>
<p>    # mcedit config.php</p>
<p>    or </p>
<p>    # vi config.php</p>
<p>    Note: please read and fill all required fields with coutious</p>
<p>9.  Enter bin directory, copy playsms, playsmsd, playsmsd.php, playsmsd_start to directory default</p>
<p>    # cd /usr/local/src/playsms-x.x.x/bin</p>
<p>    # cp playsmsd playsmsd.php playsmsd_start /usr/local/bin/</p>
<p>    # cp playsms /etc/default/</p>
<p>    Note: please note the different between playsms and playsmsd</p>
<p>10. Look for rc.local on /etc and its subdirectories (usualy /etc, /etc/init.d or /etc/rc.d/init.d)</p>
<p>    Edit rc.local and put: </p>
<p>    &#8221;/usr/local/bin/playsmsd_start&#8221; (without quotes)</p>
<p>    on the bottom of the file (before exit if theres exit command). This way playsmsd_start </p>
<p>    will start automatically on boot. </p>
<p>    Note: you need &#8216;root&#8217; access to do this</p>
<p>11  Browse http://localhost/playsms/ and login using default administrator user</p>
<p>    username: admin</p>
<p>    password: admin</p>
<p>12. At this point you should be able to login to playSMS web interface and manage playSMS</p>
<div>There are quite a few requirements though, notably you must have <a href="http://www.easysoft.com/developer/languages/php/pear-db-odbc.html">PEAR DB installed</a>, and also <a href="http://meiert.com/en/blog/20071029/java-and-lynx-for-mac/">Lynx</a> browser. More to follow&#8230;</div>
<div>To install wget, <a href="http://ftp.gnu.org/gnu/wget/">get it here</a>, <a href="http://wget.addictivecode.org/FrequentlyAskedQuestions?action=show&amp;redirect=Faq#head-7c2b3e518b3e1dc0444f7d19a7fdea3326c0dffa">read this</a>. For the <a href="http://www.macosxhints.com/article.php?story=20001105230841401">lynx install</a>, I used /usr/share/libtool/config.guess instead of /usr/libexec/config.guess. </div>
]]></content:encoded>
			<wfw:commentRss>http://www.pokeroconnor.com/free-sms-gateways/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Server Timezones</title>
		<link>http://www.pokeroconnor.com/server-timezones/</link>
		<comments>http://www.pokeroconnor.com/server-timezones/#comments</comments>
		<pubDate>Sun, 19 Apr 2009 21:47:38 +0000</pubDate>
		<dc:creator>PokerOConnor</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.pokeroconnor.com/?p=208</guid>
		<description><![CDATA[You can override your server’s timezone setting using php&#8217;s date_default_timezone_set. It is a really good idea, in my opinion, to use this at the start of your scripts that work with timestamps. Reason being, you can transfer scripts between servers and they will always work, which wouldn&#8217;t necessarily be the case if they depend on a servers timezone [...]]]></description>
			<content:encoded><![CDATA[<p>You can override your server’s timezone setting using php&#8217;s <a href="http://ie2.php.net/manual/en/function.date-default-timezone-set.php">date_default_timezone_set</a>. It is a really good idea, in my opinion, to use this at the start of your scripts that work with timestamps. Reason being, you can transfer scripts between servers and they will always work, which wouldn&#8217;t necessarily be the case if they depend on a servers timezone e.g if you are calculating a unixtime value in your script.</p>
<p>For example, I had an Ajax Calendar app that used Unixtime values to calculate which data to retrieve from a MySQL db. This worked fine on my dev server, whose server timezone was GMT, but when I transferred the code to my production server, which runs on E.T, it was not retrieving the correct data! This was a major pain to debug, as the code itself was fine of course, and was solved with a single line of code:</p>
<blockquote><p>date_default_timezone_set(&#8220;GMT&#8221;);</p></blockquote>
<p>Place this at the start of any script that has a dependency on the server timezone, and you can port your code to any server regardless of its timezone. If you don&#8217;t know your server&#8217;s timezone, <a href="http://ie2.php.net/date_default_timezone_get">date_default_timezone_get()</a> will give it to you.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pokeroconnor.com/server-timezones/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL datetime Formatting</title>
		<link>http://www.pokeroconnor.com/mysql-datetime-formatting/</link>
		<comments>http://www.pokeroconnor.com/mysql-datetime-formatting/#comments</comments>
		<pubDate>Fri, 10 Apr 2009 22:48:25 +0000</pubDate>
		<dc:creator>PokerOConnor</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.pokeroconnor.com/?p=179</guid>
		<description><![CDATA[Say you are using MySQL datetime as the format for your dates, so when you output it you get 2009-03-21, which isn&#8217;t exactly user friendly nice to read. Say you want instead to have March 21st, 2009. There are of course two main ways to do this, convert the datetime field in php using mktime() to Unix [...]]]></description>
			<content:encoded><![CDATA[<p>Say you are using MySQL datetime as the format for your dates, so when you output it you get 2009-03-21, which isn&#8217;t exactly user friendly nice to read. Say you want instead to have March 21st, 2009. There are of course two main ways to do this, convert the datetime field in php using mktime() to Unix Time, and then format with date() from there. Bit of a pain, and heavier processing then the second way, which is to use MySQL&#8217;s <a href="http://dev.mysql.com/doc/refman/4.1/en/date-and-time-functions.html#function_date-format">DATE_FORMAT</a>. Check out that page, seriously &#8211; the list of date modifiers is very comprehensive, and listed here for your pleasure at the bottom of the page.</p>
<p>There&#8217;s a <a href="http://www.webmasterworld.com/forum88/11945.htm">great forum post here</a>, mentioning both methods &#8211; its well worth a look as the examples are simple and clear.</p>
<p>Quick example would be what we mentioned above, i.e. getting your date in the format of March 21st, 2009. Look how quick it is in MySQL compared to PHP:</p>
<p>SELECT DATE_format(olddate, &#8216;%M %D, %Y&#8217;) as newdate FROM table;</p>
<p>&#8216;olddate&#8217; is the name of your date field in datetime format, and &#8216;newdate&#8217; is the new var representing the nicely and newly formatted date!</p>
<table border="1">
<colgroup>
<col></col>
<col></col>
</colgroup>
<tbody>
<tr>
<td><span class="bold"><strong>Specifier</strong></span></td>
<td><span class="bold"><strong>Description</strong></span></td>
</tr>
<tr>
<td><code class="literal">%a</code></td>
<td>Abbreviated weekday name (<code class="literal">Sun</code>..<code class="literal">Sat</code>)</td>
</tr>
<tr>
<td><code class="literal">%b</code></td>
<td>Abbreviated month name (<code class="literal">Jan</code>..<code class="literal">Dec</code>)</td>
</tr>
<tr>
<td><code class="literal">%c</code></td>
<td>Month, numeric (<code class="literal">0</code>..<code class="literal">12</code>)</td>
</tr>
<tr>
<td><code class="literal">%D</code></td>
<td>Day of the month with English suffix (<code class="literal">0th</code>, <code class="literal">1st</code>, <code class="literal">2nd</code>, <code class="literal">3rd</code>, …)</td>
</tr>
<tr>
<td><code class="literal">%d</code></td>
<td>Day of the month, numeric (<code class="literal">00</code>..<code class="literal">31</code>)</td>
</tr>
<tr>
<td><code class="literal">%e</code></td>
<td>Day of the month, numeric (<code class="literal">0</code>..<code class="literal">31</code>)</td>
</tr>
<tr>
<td><code class="literal">%f</code></td>
<td>Microseconds (<code class="literal">000000</code>..<code class="literal">999999</code>)</td>
</tr>
<tr>
<td><code class="literal">%H</code></td>
<td>Hour (<code class="literal">00</code>..<code class="literal">23</code>)</td>
</tr>
<tr>
<td><code class="literal">%h</code></td>
<td>Hour (<code class="literal">01</code>..<code class="literal">12</code>)</td>
</tr>
<tr>
<td><code class="literal">%I</code></td>
<td>Hour (<code class="literal">01</code>..<code class="literal">12</code>)</td>
</tr>
<tr>
<td><code class="literal">%i</code></td>
<td>Minutes, numeric (<code class="literal">00</code>..<code class="literal">59</code>)</td>
</tr>
<tr>
<td><code class="literal">%j</code></td>
<td>Day of year (<code class="literal">001</code>..<code class="literal">366</code>)</td>
</tr>
<tr>
<td><code class="literal">%k</code></td>
<td>Hour (<code class="literal">0</code>..<code class="literal">23</code>)</td>
</tr>
<tr>
<td><code class="literal">%l</code></td>
<td>Hour (<code class="literal">1</code>..<code class="literal">12</code>)</td>
</tr>
<tr>
<td><code class="literal">%M</code></td>
<td>Month name (<code class="literal">January</code>..<code class="literal">December</code>)</td>
</tr>
<tr>
<td><code class="literal">%m</code></td>
<td>Month, numeric (<code class="literal">00</code>..<code class="literal">12</code>)</td>
</tr>
<tr>
<td><code class="literal">%p</code></td>
<td><code class="literal">AM</code> or <code class="literal">PM</code></td>
</tr>
<tr>
<td><code class="literal">%r</code></td>
<td>Time, 12-hour (<code class="literal">hh:mm:ss</code> followed by <code class="literal">AM</code> or <code class="literal">PM</code>)</td>
</tr>
<tr>
<td><code class="literal">%S</code></td>
<td>Seconds (<code class="literal">00</code>..<code class="literal">59</code>)</td>
</tr>
<tr>
<td><code class="literal">%s</code></td>
<td>Seconds (<code class="literal">00</code>..<code class="literal">59</code>)</td>
</tr>
<tr>
<td><code class="literal">%T</code></td>
<td>Time, 24-hour (<code class="literal">hh:mm:ss</code>)</td>
</tr>
<tr>
<td><code class="literal">%U</code></td>
<td>Week (<code class="literal">00</code>..<code class="literal">53</code>), where Sunday is the first day of the week</td>
</tr>
<tr>
<td><code class="literal">%u</code></td>
<td>Week (<code class="literal">00</code>..<code class="literal">53</code>), where Monday is the first day of the week</td>
</tr>
<tr>
<td><code class="literal">%V</code></td>
<td>Week (<code class="literal">01</code>..<code class="literal">53</code>), where Sunday is the first day of the week; used with <code class="literal">%X</code></td>
</tr>
<tr>
<td><code class="literal">%v</code></td>
<td>Week (<code class="literal">01</code>..<code class="literal">53</code>), where Monday is the first day of the week; used with <code class="literal">%x</code></td>
</tr>
<tr>
<td><code class="literal">%W</code></td>
<td>Weekday name (<code class="literal">Sunday</code>..<code class="literal">Saturday</code>)</td>
</tr>
<tr>
<td><code class="literal">%w</code></td>
<td>Day of the week (<code class="literal">0</code>=Sunday..<code class="literal">6</code>=Saturday)</td>
</tr>
<tr>
<td><code class="literal">%X</code></td>
<td>Year for the week where Sunday is the first day of the week, numeric, four digits; used with <code class="literal">%V</code></td>
</tr>
<tr>
<td><code class="literal">%x</code></td>
<td>Year for the week, where Monday is the first day of the week, numeric, four digits; used with <code class="literal">%v</code></td>
</tr>
<tr>
<td><code class="literal">%Y</code></td>
<td>Year, numeric, four digits</td>
</tr>
<tr>
<td><code class="literal">%y</code></td>
<td>Year, numeric (two digits)</td>
</tr>
<tr>
<td><code class="literal">%%</code></td>
<td>A literal “<span class="quote"><code class="literal">%</code></span>” character</td>
</tr>
<tr>
<td><code class="literal">%<em><code>x</code></em></code></td>
<td><em><code>x</code></em>, for any “<span class="quote"><em><code>x</code></em></span>” not listed above</td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://www.pokeroconnor.com/mysql-datetime-formatting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL Handy Tricks</title>
		<link>http://www.pokeroconnor.com/mysql-handy-tricks/</link>
		<comments>http://www.pokeroconnor.com/mysql-handy-tricks/#comments</comments>
		<pubDate>Tue, 17 Feb 2009 21:36:39 +0000</pubDate>
		<dc:creator>PokerOConnor</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.pokeroconnor.com/?p=51</guid>
		<description><![CDATA[Let&#8217;s get the ball rolling wit this handy one about inserting csv or other delimited data to mysql dbs using INFILEs. This looks  like a basic php version too. When getting the annoying error 1075 &#8220;Incorrect table definition; There can only be one auto column and it must be defined as a key&#8221; when trying to [...]]]></description>
			<content:encoded><![CDATA[<p>Let&#8217;s get the ball rolling wit this handy one about <a href="http://www.modwest.com/help/kb6-253.html">inserting csv or other delimited data to mysql</a> dbs using INFILEs. This looks  like a <a href="http://www.chipmunk-scripts.com/board/index.php?forumID=43&amp;ID=9602">basic php version</a> too.</p>
<p>When getting the annoying <strong>error 1075</strong> &#8220;Incorrect table definition; There can only be one auto column and it must be defined as a key&#8221; when trying to add a new primary key, this page has an <a href="http://mysql-tips.blogspot.com/2005/04/resolving-error-1075-incorrect-table.html">awesome solution</a>.</p>
<p>Using sprintf() to zerofill variables, handy like so:<br />
<code><br />
$zeroball1 = $this-&gt;escape($result-&gt;ball1);<br />
$zeroball2 = sprintf("%02d",$zeroball1);<br />
echo $zeroball2;</code></p>
<h2>Zend Framework and MySQL</h2>
<p>For counting across rows, first check out the excellent <a href="http://dev.mysql.com/doc/refman/5.1/en/counting-rows.html">official mysql page on row counting</a>. Then to apply it to Zend framework, this is probably the <a href="http://framework.zend.com/manual/en/zend.db.select.html">best starting place for MySql select queries in Zend FW</a>, and I check it regularly. Basically, to run a mysql query like <strong><em>SELECT `results`.`bonus`, COUNT(*) AS `counter` FROM `results` WHERE (draw = 0) GROUP BY `bonus`;</em></strong> <span style="font-weight: normal;">you need the following in your model. Note the </span>&#8216;counter&#8217; =&gt; &#8216;COUNT(*)&#8217; <span style="font-weight: normal;">syntax&#8230;</span></p>
<p><code><span> </span>$query = $db-&gt;select()  </code></p>
<p><code><span> </span>-&gt;where("draw = $draw_val")</code></p>
<p><code><span> </span>-&gt;from('results',array('bonus','counter' =&gt; 'COUNT(*)'))</code></p>
<p><code><span> </span> <span> </span>-&gt;group('bonus');</code></p>
<p>For further and more detailed quality examples of Zend and MySql, <a href="http://zendframework.com/issues/browse/ZF-5319">this is good</a>. Check out lars&#8217; comment here on <a href="http://discussion.dreamhost.com/showflat.pl?Cat=&amp;Board=forum_programming&amp;Number=9112">counting across multiple tables</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pokeroconnor.com/mysql-handy-tricks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

