Author: jwage
Date: 2008-08-27 06:12:09 +0100 (Wed, 27 Aug 2008)
New Revision: 4842

Modified:
   branches/1.0/lib/Doctrine/Template/Listener/Timestampable.php
   branches/1.0/lib/Doctrine/Template/Timestampable.php
Log:
fixes #1325


Modified: branches/1.0/lib/Doctrine/Template/Listener/Timestampable.php
===================================================================
--- branches/1.0/lib/Doctrine/Template/Listener/Timestampable.php       
2008-08-27 05:11:09 UTC (rev 4841)
+++ branches/1.0/lib/Doctrine/Template/Listener/Timestampable.php       
2008-08-27 05:12:09 UTC (rev 4842)
@@ -60,12 +60,12 @@
     public function preInsert(Doctrine_Event $event)
     {
         if( ! $this->_options['created']['disabled']) {
-            $createdName = $this->_options['created']['name'];
+            $createdName = 
$event->getInvoker()->getTable()->getFieldName($this->_options['created']['name']);
             $event->getInvoker()->$createdName = 
$this->getTimestamp('created');
         }
 
         if( ! $this->_options['updated']['disabled'] && 
$this->_options['updated']['onInsert']) {
-            $updatedName = $this->_options['updated']['name'];
+            $updatedName = 
$event->getInvoker()->getTable()->getFieldName($this->_options['updated']['name']);
             $event->getInvoker()->$updatedName = 
$this->getTimestamp('updated');
         }
     }
@@ -79,7 +79,7 @@
     public function preUpdate(Doctrine_Event $event)
     {
         if( ! $this->_options['updated']['disabled']) {
-            $updatedName = $this->_options['updated']['name'];
+            $updatedName = 
$event->getInvoker()->getTable()->getFieldName($this->_options['updated']['name']);
             $event->getInvoker()->$updatedName = 
$this->getTimestamp('updated');
         }
     }

Modified: branches/1.0/lib/Doctrine/Template/Timestampable.php
===================================================================
--- branches/1.0/lib/Doctrine/Template/Timestampable.php        2008-08-27 
05:11:09 UTC (rev 4841)
+++ branches/1.0/lib/Doctrine/Template/Timestampable.php        2008-08-27 
05:12:09 UTC (rev 4842)
@@ -41,17 +41,19 @@
      * @var string
      */
     protected $_options = array('created' =>  array('name'          =>  
'created_at',
+                                                    'alias'         =>  null,
                                                     'type'          =>  
'timestamp',
                                                     'format'        =>  'Y-m-d 
H:i:s',
-                                                    'disabled'      => false,
-                                                    'expression'    => false,
+                                                    'disabled'      =>  false,
+                                                    'expression'    =>  false,
                                                     'options'       =>  
array()),
                                 'updated' =>  array('name'          =>  
'updated_at',
+                                                    'alias'         =>  null,
                                                     'type'          =>  
'timestamp',
                                                     'format'        =>  'Y-m-d 
H:i:s',
-                                                    'disabled'      => false,
-                                                    'expression'    => false,
-                                                    'onInsert'      => true,
+                                                    'disabled'      =>  false,
+                                                    'expression'    =>  false,
+                                                    'onInsert'      =>  true,
                                                     'options'       =>  
array()));
 
     /**
@@ -73,11 +75,19 @@
     public function setTableDefinition()
     {
         if( ! $this->_options['created']['disabled']) {
-            $this->hasColumn($this->_options['created']['name'], 
$this->_options['created']['type'], null, 
$this->_options['created']['options']);
+            $name = $this->_options['created']['name'];
+            if ($this->_options['created']['alias']) {
+                $name .= ' as ' . $this->_options['created']['alias'];
+            }
+            $this->hasColumn($name, $this->_options['created']['type'], null, 
$this->_options['created']['options']);
         }
 
         if( ! $this->_options['updated']['disabled']) {
-            $this->hasColumn($this->_options['updated']['name'], 
$this->_options['updated']['type'], null, 
$this->_options['updated']['options']);
+            $name = $this->_options['updated']['name'];
+            if ($this->_options['updated']['alias']) {
+                $name .= ' as ' . $this->_options['updated']['alias'];
+            }
+            $this->hasColumn($name, $this->_options['updated']['type'], null, 
$this->_options['updated']['options']);
         }
 
         $this->addListener(new 
Doctrine_Template_Listener_Timestampable($this->_options));


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"doctrine-svn" group.
 To post to this group, send email to [email protected]
 To unsubscribe from this group, send email to [EMAIL PROTECTED]
 For more options, visit this group at 
http://groups.google.co.uk/group/doctrine-svn?hl=en-GB
-~----------~----~----~----~------~----~------~--~---

Reply via email to