<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Update and create timestamps with MySQL</title>
	<atom:link href="http://gusiev.com/2009/04/update-and-create-timestamps-with-mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://gusiev.com/2009/04/update-and-create-timestamps-with-mysql/</link>
	<description>How to make your web application</description>
	<pubDate>Fri, 30 Jul 2010 11:55:48 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5</generator>
		<item>
		<title>By: Hung Romo</title>
		<link>http://gusiev.com/2009/04/update-and-create-timestamps-with-mysql/#comment-391</link>
		<dc:creator>Hung Romo</dc:creator>
		<pubDate>Wed, 14 Jul 2010 19:16:00 +0000</pubDate>
		<guid isPermaLink="false">http://gusiev.com/?p=16#comment-391</guid>
		<description>Your weblog is incredibly helpful,I need to connect with u,could i sent e-mail to you?</description>
		<content:encoded><![CDATA[Your weblog is incredibly helpful,I need to connect with u,could i sent e-mail to you?
]]></content:encoded>
	</item>
	<item>
		<title>By: ahjan</title>
		<link>http://gusiev.com/2009/04/update-and-create-timestamps-with-mysql/#comment-130</link>
		<dc:creator>ahjan</dc:creator>
		<pubDate>Fri, 22 Jan 2010 09:29:16 +0000</pubDate>
		<guid isPermaLink="false">http://gusiev.com/?p=16#comment-130</guid>
		<description>hi! for the "insert into test_table(stamp_created, stamp_updated) values(null, null); " statement.. how would u write it in php codings so that whenever a new data is created, it will automatically include the date created.. 

bcux right now i tried writing the insert in mysql codings but it only shows null null for other column info.. only the date modified n created are updated..

as im using a webpage to add data it doesn shows the created time.. rather it shows the "0000-00-00 00:00:00". only my updated column can b updated..

pls help thks!</description>
		<content:encoded><![CDATA[hi! for the &#8220;insert into test_table(stamp_created, stamp_updated) values(null, null); &#8221; statement.. how would u write it in php codings so that whenever a new data is created, it will automatically include the date created.. 

bcux right now i tried writing the insert in mysql codings but it only shows null null for other column info.. only the date modified n created are updated..

as im using a webpage to add data it doesn shows the created time.. rather it shows the &#8220;0000-00-00 00:00:00&#8243;. only my updated column can b updated..

pls help thks!
]]></content:encoded>
	</item>
	<item>
		<title>By: Ped</title>
		<link>http://gusiev.com/2009/04/update-and-create-timestamps-with-mysql/#comment-122</link>
		<dc:creator>Ped</dc:creator>
		<pubDate>Wed, 16 Dec 2009 10:09:40 +0000</pubDate>
		<guid isPermaLink="false">http://gusiev.com/?p=16#comment-122</guid>
		<description>I don't get it. If you already have a "workaround" which does force you to insert null, why don't you insert NOW() instead of null?

With trigger workaround you gain the advantage to not mention "stamp_created" at all, so I can see a point there, although I personally refrain from such trigger usage, and I rather add NOW() into my inserts, which is IMHO much better then using "null" hack described here.

Because honestly, this looks more like a bug to me. If you want 0000-00-00 as default, why don't you get it? I would be not shocked if MySQL would decide to change this behaviour later in future and "fix" it. (although I would rather welcome to have 2+ columns default NOW fix :) )</description>
		<content:encoded><![CDATA[I don&#8217;t get it. If you already have a &#8220;workaround&#8221; which does force you to insert null, why don&#8217;t you insert NOW() instead of null?

With trigger workaround you gain the advantage to not mention &#8220;stamp_created&#8221; at all, so I can see a point there, although I personally refrain from such trigger usage, and I rather add NOW() into my inserts, which is IMHO much better then using &#8220;null&#8221; hack described here.

Because honestly, this looks more like a bug to me. If you want 0000-00-00 as default, why don&#8217;t you get it? I would be not shocked if MySQL would decide to change this behaviour later in future and &#8220;fix&#8221; it. (although I would rather welcome to have 2+ columns default NOW fix <img src='http://gusiev.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> )
]]></content:encoded>
	</item>
	<item>
		<title>By: sl fuqua</title>
		<link>http://gusiev.com/2009/04/update-and-create-timestamps-with-mysql/#comment-117</link>
		<dc:creator>sl fuqua</dc:creator>
		<pubDate>Wed, 25 Nov 2009 22:01:41 +0000</pubDate>
		<guid isPermaLink="false">http://gusiev.com/?p=16#comment-117</guid>
		<description>It's crazy to have to do this. With dynamic websites, blogs, and such, it would seem obviously intrinsic that the original creation date should be maintained automatically somehow.

Oh the naivety of the `nub` :). Thanks for saving me several hours work figuring this out.

Regards,
sl</description>
		<content:encoded><![CDATA[It&#8217;s crazy to have to do this. With dynamic websites, blogs, and such, it would seem obviously intrinsic that the original creation date should be maintained automatically somehow.

Oh the naivety of the `nub` :). Thanks for saving me several hours work figuring this out.

Regards,
<br />sl
]]></content:encoded>
	</item>
	<item>
		<title>By: Samo</title>
		<link>http://gusiev.com/2009/04/update-and-create-timestamps-with-mysql/#comment-113</link>
		<dc:creator>Samo</dc:creator>
		<pubDate>Wed, 18 Nov 2009 09:38:21 +0000</pubDate>
		<guid isPermaLink="false">http://gusiev.com/?p=16#comment-113</guid>
		<description>thnx Bogdan, good trick</description>
		<content:encoded><![CDATA[thnx Bogdan, good trick
]]></content:encoded>
	</item>
	<item>
		<title>By: Mehedi Hasan</title>
		<link>http://gusiev.com/2009/04/update-and-create-timestamps-with-mysql/#comment-111</link>
		<dc:creator>Mehedi Hasan</dc:creator>
		<pubDate>Thu, 12 Nov 2009 09:44:35 +0000</pubDate>
		<guid isPermaLink="false">http://gusiev.com/?p=16#comment-111</guid>
		<description>thanks a lot for the great tips...</description>
		<content:encoded><![CDATA[thanks a lot for the great tips&#8230;
]]></content:encoded>
	</item>
	<item>
		<title>By: Bogdan Gusiev</title>
		<link>http://gusiev.com/2009/04/update-and-create-timestamps-with-mysql/#comment-65</link>
		<dc:creator>Bogdan Gusiev</dc:creator>
		<pubDate>Thu, 18 Jun 2009 20:00:19 +0000</pubDate>
		<guid isPermaLink="false">http://gusiev.com/?p=16#comment-65</guid>
		<description>I was doing the same experiments that you mentioned in your blog. The trick above is the only one way to have both timestamps in current MySQL version.</description>
		<content:encoded><![CDATA[I was doing the same experiments that you mentioned in your blog. The trick above is the only one way to have both timestamps in current MySQL version.
]]></content:encoded>
	</item>
	<item>
		<title>By: Red Five</title>
		<link>http://gusiev.com/2009/04/update-and-create-timestamps-with-mysql/#comment-64</link>
		<dc:creator>Red Five</dc:creator>
		<pubDate>Thu, 18 Jun 2009 19:01:58 +0000</pubDate>
		<guid isPermaLink="false">http://gusiev.com/?p=16#comment-64</guid>
		<description>Oops, misread the default value thing. I just tried it, and by default it'll insert a timestamp value of '0000-00-00 00:00:00'.</description>
		<content:encoded><![CDATA[Oops, misread the default value thing. I just tried it, and by default it&#8217;ll insert a timestamp value of &#8216;0000-00-00 00:00:00&#8242;.
]]></content:encoded>
	</item>
	<item>
		<title>By: Red Five</title>
		<link>http://gusiev.com/2009/04/update-and-create-timestamps-with-mysql/#comment-63</link>
		<dc:creator>Red Five</dc:creator>
		<pubDate>Thu, 18 Jun 2009 18:58:22 +0000</pubDate>
		<guid isPermaLink="false">http://gusiev.com/?p=16#comment-63</guid>
		<description>There's a simpler way: simply make your stamp_updated column first, and set its "on update" attribute to current_timestamp, with no default value. Then follow with your stamp_created column, and set nothing for default value or "on update". Timestamp values default to the current timestamp, according to http://www.haidongji.com/2009/01/04/interesting-things-about-timestamp-data-type-in-mysql/.</description>
		<content:encoded><![CDATA[There&#8217;s a simpler way: simply make your stamp_updated column first, and set its &#8220;on update&#8221; attribute to current_timestamp, with no default value. Then follow with your stamp_created column, and set nothing for default value or &#8220;on update&#8221;. Timestamp values default to the current timestamp, according to <a href="http://www.haidongji.com/2009/01/04/interesting-things-about-timestamp-data-type-in-mysql/" rel="nofollow">http://www.haidongji.com/2009/01/04/interesting-things-about-timestamp-data-type-in-mysql/</a>.
]]></content:encoded>
	</item>
	<item>
		<title>By: Andy</title>
		<link>http://gusiev.com/2009/04/update-and-create-timestamps-with-mysql/#comment-62</link>
		<dc:creator>Andy</dc:creator>
		<pubDate>Wed, 17 Jun 2009 22:54:42 +0000</pubDate>
		<guid isPermaLink="false">http://gusiev.com/?p=16#comment-62</guid>
		<description>"Note that it is necessary to enter nulls into both columns during ‘insert’:"

Actually, you only need the null for the stamp_created as the stamp_updated will get updated automatically.

mysql&#62; insert into test_table(stamp_created) values(NULL); 
Query OK, 1 row affected (0.00 sec)

mysql&#62; select * from test_table;

+----+---------------------+---------------------+
&#124; id &#124; stamp_created       &#124; stamp_updated       &#124;
+----+---------------------+---------------------+
&#124;  5 &#124; 2009-06-17 15:54:18 &#124; 2009-06-17 15:54:18 &#124; 
+----+---------------------+---------------------+</description>
		<content:encoded><![CDATA[&#8220;Note that it is necessary to enter nulls into both columns during ‘insert’:&#8221;

Actually, you only need the null for the stamp_created as the stamp_updated will get updated automatically.

mysql&gt; insert into test_table(stamp_created) values(NULL); 
<br />Query OK, 1 row affected (0.00 sec)

mysql&gt; select * from test_table;

+&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+
<br />| id | stamp_created       | stamp_updated       |
<br />+&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+
<br />|  5 | 2009-06-17 15:54:18 | 2009-06-17 15:54:18 | 
<br />+&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+
]]></content:encoded>
	</item>
</channel>
</rss>
