]> git.andy128k.dev Git - ipf-legacy-orm.git/commitdiff
exclude timestampable's fields by default
authorAndrey Kutejko <andy128k@gmail.com>
Mon, 15 Jul 2013 18:27:04 +0000 (21:27 +0300)
committerAndrey Kutejko <andy128k@gmail.com>
Mon, 15 Jul 2013 18:27:04 +0000 (21:27 +0300)
ipf/orm/template/timestampable.php

index 9a5b9e75291a05f767b8c2e00be2261110c6e51b..7c0c1fb62f31756ee4f6ec5b04d0a74fc530dcd3 100644 (file)
@@ -1,19 +1,27 @@
 <?php
 
-class IPF_ORM_Template_Timestampable extends IPF_ORM_Template{
-    protected $_options = array('created' =>  array('name'          =>  'created_at',
-                                                    'type'          =>  'timestamp',
-                                                    'format'        =>  'Y-m-d H:i:s',
-                                                    'disabled'      => false,
-                                                    'expression'    => false,
-                                                    'options'       =>  array()),
-                                'updated' =>  array('name'          =>  'updated_at',
-                                                    'type'          =>  'timestamp',
-                                                    'format'        =>  'Y-m-d H:i:s',
-                                                    'disabled'      => false,
-                                                    'expression'    => false,
-                                                    'onInsert'      => true,
-                                                    'options'       =>  array()));
+class IPF_ORM_Template_Timestampable extends IPF_ORM_Template
+{
+    protected $_options = array(
+        'created' => array(
+            'name'        => 'created_at',
+            'type'        => 'timestamp',
+            'format'      => 'Y-m-d H:i:s',
+            'disabled'    => false,
+            'expression'  => false,
+            'options'     => array('exclude' => true),
+        ),
+        'updated' => array(
+            'name'        => 'updated_at',
+            'type'        => 'timestamp',
+            'format'      => 'Y-m-d H:i:s',
+            'disabled'    => false,
+            'expression'  => false,
+            'onInsert'    => true,
+            'exclude'     => true,
+            'options'     => array('exclude' => true),
+        ),
+    );
 
     public function __construct(array $options = array())
     {
@@ -22,12 +30,13 @@ class IPF_ORM_Template_Timestampable extends IPF_ORM_Template{
 
     public function setTableDefinition()
     {
-        if( ! $this->_options['created']['disabled']) {
+        if (!$this->_options['created']['disabled']) {
             $this->hasColumn($this->_options['created']['name'], $this->_options['created']['type'], null, $this->_options['created']['options']);
         }
-        if( ! $this->_options['updated']['disabled']) {
+        if (!$this->_options['updated']['disabled']) {
             $this->hasColumn($this->_options['updated']['name'], $this->_options['updated']['type'], null, $this->_options['updated']['options']);
         }
         $this->getTable()->listeners['Timestampable_'.print_r($this->_options, true)] = new IPF_ORM_Template_Listener_Timestampable($this->_options);
     }
 }
+