From 04c4c5861aed10f86d819861f4f13aa579254a04 Mon Sep 17 00:00:00 2001 From: Andrey Kutejko Date: Mon, 15 Jul 2013 21:27:04 +0300 Subject: [PATCH] exclude timestampable's fields by default --- ipf/orm/template/timestampable.php | 41 ++++++++++++++++++------------ 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/ipf/orm/template/timestampable.php b/ipf/orm/template/timestampable.php index 9a5b9e7..7c0c1fb 100644 --- a/ipf/orm/template/timestampable.php +++ b/ipf/orm/template/timestampable.php @@ -1,19 +1,27 @@ 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); } } + -- 2.49.0