<?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>Evilprofessor.co.uk &#187; Doctrine</title>
	<atom:link href="http://www.evilprofessor.co.uk/category/internet/doctrine/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.evilprofessor.co.uk</link>
	<description>The website of Steven Lloyd Watkin</description>
	<lastBuildDate>Thu, 04 Aug 2011 09:56:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Doctrine: DATETIME default NOW()</title>
		<link>http://www.evilprofessor.co.uk/222-doctrine-datetime-default-now/</link>
		<comments>http://www.evilprofessor.co.uk/222-doctrine-datetime-default-now/#comments</comments>
		<pubDate>Wed, 30 Dec 2009 18:30:04 +0000</pubDate>
		<dc:creator>Steven Lloyd Watkin</dc:creator>
				<category><![CDATA[Doctrine]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Programming]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[mySQL]]></category>
		<category><![CDATA[orm]]></category>
		<category><![CDATA[schema]]></category>
		<category><![CDATA[yaml]]></category>

		<guid isPermaLink="false">http://www.evilprofessor.co.uk/?p=222</guid>
		<description><![CDATA[I&#8217;ve been struggling with setting up a database schema for a new Zend Framework project. I&#8217;m using trying to use Doctrine ORM for my database models. I need to set up the schema so that it allowed me to set a default date and time for a `datetime` column, e.g. when adding a new message [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been struggling with setting up a database schema for a new <a href="http://framework.zend.com" class="kblinker" target="_blank" title="More about Zend Framework &raquo;">Zend Framework</a> project. I&#8217;m <del datetime="2009-12-30T17:03:47+00:00">using</del> trying to use <a href="http://www.doctrine-project.org/" class="kblinker" target="_blank" title="More about Doctrine &raquo;">Doctrine</a> ORM for my database models. I need to set up the schema so  that it allowed me to set a default date and time for a `datetime` column, e.g. when adding a new message I get the current timestamp. After much searching and experimenting I found the solution so I&#8217;m sharing it.</p>
<p>In your schema <a href="http://www.yaml.org/" class="kblinker" target="_blank" title="More about yaml &raquo;">YAML</a> file simply do the following:</p>
<pre name="code" class="yaml">
Message:
  actAs:
    Timestampable:
      created:
        name: created_at
        type: timestamp
        format: Y-m-d H:i:s
      updated:
        name: last_updated
        type: timestamp
        format: Y-m-d H:i:s
  columns:
    id:
      type: integer
      primary: true
      autoincrement: true
    name: string(255)
    email: string(300)
    message: string(2000)
</pre>
<p>If on the other hand you don&#8217;t want an `updated_at` column you can use the following:</p>
<pre name="code" class="yaml">
Message:
  actAs:
    Timestampable:
      created:
        name: created_at
        type: timestamp
        format: Y-m-d H:i:s
      updated:
        disabled: true
  columns:
    id:
      type: integer
      primary: true
      autoincrement: true
    name: string(255)
    email: string(300)
    message: string(2000)
</pre>
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.evilprofessor.co.uk%2F222-doctrine-datetime-default-now%2F&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>]]></content:encoded>
			<wfw:commentRss>http://www.evilprofessor.co.uk/222-doctrine-datetime-default-now/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
