<?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>LAMP with ·dotmanila &#187; now()</title>
	<atom:link href="http://dotmanila.com/blog/tag/now/feed/" rel="self" type="application/rss+xml" />
	<link>http://dotmanila.com/blog</link>
	<description>Linux, Apache, PHP, MySQL Musings</description>
	<lastBuildDate>Wed, 01 Feb 2012 23:32:54 +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>MySQL Default DATETIME Value &#8211; A Quick Rant</title>
		<link>http://dotmanila.com/blog/2009/11/mysql-default-datetime-value-a-quick-rant/</link>
		<comments>http://dotmanila.com/blog/2009/11/mysql-default-datetime-value-a-quick-rant/#comments</comments>
		<pubDate>Thu, 19 Nov 2009 16:39:22 +0000</pubDate>
		<dc:creator>jervin</dc:creator>
				<category><![CDATA[BSD/Mac OSX]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[default datetime value]]></category>
		<category><![CDATA[now()]]></category>

		<guid isPermaLink="false">http://dotmanila.com/blog/?p=106</guid>
		<description><![CDATA[I was reviewing a year old code which I am adding a feature to. It so happened I came to a familiar issue about having two timestamp/datetime columns, one which should have the CURRENT_DATE / NOW() as default value and the other with an &#8216;ON UPDATE CURENT_TIMESTAMP&#8217;. Examine the simple structure below: CREATE TABLE `stories` [...]]]></description>
			<content:encoded><![CDATA[<p>I was reviewing a year old code which I am adding a feature to. It so happened I came to a familiar issue about having two timestamp/datetime columns, one which should have the CURRENT_DATE / NOW() as default value and the other with an &#8216;ON UPDATE CURENT_TIMESTAMP&#8217;. Examine the simple structure below:</p>
<pre class="brush: sql;ruler: true;">
CREATE TABLE `stories` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`title` VARCHAR( 255 ) NOT NULL ,
`text` TEXT NOT NULL ,
`creationdate` DATETIME NOT NULL ,
`lastupdate` TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE = MYISAM</pre>
<p>When you want to store stories, you would also want to record when it was originally created as well track the last time it was updated. The problem here is that adding a `DEFAULT NOW()` clause will not work for the `CREATE TABLE` query above as it is not supported. So when your insert a new story you will have to explicitly add a `NOW()` function for the `creationdate` row so it will reflect the current date as creation date. This should&#8217;ve been a simple schema functionality, turns out after more than a year MySQL seems to ignore for some reason.</p>
<p>Go on have yourself a read here http://bugs.mysql.com/bug.php?id=27645</p>
<p>How about you, how many times have you have to work around this from your application code?</p>
]]></content:encoded>
			<wfw:commentRss>http://dotmanila.com/blog/2009/11/mysql-default-datetime-value-a-quick-rant/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

