From b4625a845446963745198d3ab502fde7f7ba1344 Mon Sep 17 00:00:00 2001 From: Andrey Kutejko Date: Sat, 27 Jul 2013 18:47:52 +0300 Subject: [PATCH] refactor adding columns --- ipf/orm/import/builder.php | 2 +- ipf/orm/record/abstract.php | 12 ------------ ipf/orm/template/orderable.php | 2 +- ipf/orm/template/owned.php | 2 +- ipf/orm/template/sluggable.php | 2 +- ipf/orm/template/timestampable.php | 4 ++-- 6 files changed, 6 insertions(+), 18 deletions(-) diff --git a/ipf/orm/import/builder.php b/ipf/orm/import/builder.php index b0633a9..8258b5d 100644 --- a/ipf/orm/import/builder.php +++ b/ipf/orm/import/builder.php @@ -163,7 +163,7 @@ class IPF_ORM_Import_Builder $result = array(); foreach ($columns as $name => $column) { $columnName = isset($column['name']) ? $column['name']:$name; - $build = " ".'$this->hasColumn(\'' . $columnName . '\', \'' . $column['type'] . '\''; + $build = " ".'$this->getTable()->setColumn(\'' . $columnName . '\', \'' . $column['type'] . '\''; if ($column['length']) { if (is_numeric($column['length'])) diff --git a/ipf/orm/record/abstract.php b/ipf/orm/record/abstract.php index f34c98c..41fd7f7 100644 --- a/ipf/orm/record/abstract.php +++ b/ipf/orm/record/abstract.php @@ -102,18 +102,6 @@ abstract class IPF_ORM_Record_Abstract extends IPF_ORM_Access return $this; } - public function hasColumn($name, $type, $length = 2147483647, $options = "") - { - $this->_table->setColumn($name, $type, $length, $options); - } - - public function hasColumns(array $definitions) - { - foreach ($definitions as $name => $options) { - $this->hasColumn($name, $options['type'], $options['length'], $options); - } - } - public function bindQueryParts(array $queryParts) { $this->_table->bindQueryParts($queryParts); diff --git a/ipf/orm/template/orderable.php b/ipf/orm/template/orderable.php index 3d82df9..34a4d74 100644 --- a/ipf/orm/template/orderable.php +++ b/ipf/orm/template/orderable.php @@ -25,7 +25,7 @@ class IPF_ORM_Template_Orderable extends IPF_ORM_Template public function setTableDefinition() { - $this->hasColumn($this->columnName, 'integer', null, array('exclude' => $this->exclude)); + $this->getTable()->setColumn($this->columnName, 'integer', null, array('exclude' => $this->exclude)); $this->index($this->getTable()->getOption('tableName') . '_orderable_' . $this->columnName, array('fields' => array($this->columnName))); $this->getTable()->listeners['Orderable_'.$this->columnName] = new IPF_ORM_Template_Listener_Orderable($this->columnName, $this->prepend); } diff --git a/ipf/orm/template/owned.php b/ipf/orm/template/owned.php index dbe2a96..db204c0 100644 --- a/ipf/orm/template/owned.php +++ b/ipf/orm/template/owned.php @@ -28,7 +28,7 @@ class IPF_ORM_Template_Owned extends IPF_ORM_Template public function setTableDefinition() { - $this->hasColumn($this->columnName, 'integer', null, array( + $this->getTable()->setColumn($this->columnName, 'integer', null, array( 'exclude' => $this->exclude, 'verbose' => $this->verbose, )); diff --git a/ipf/orm/template/sluggable.php b/ipf/orm/template/sluggable.php index 35e5700..a73d120 100644 --- a/ipf/orm/template/sluggable.php +++ b/ipf/orm/template/sluggable.php @@ -22,7 +22,7 @@ class IPF_ORM_Template_Sluggable extends IPF_ORM_Template public function setTableDefinition() { - $this->hasColumn($this->_options['name'], $this->_options['type'], $this->_options['length'], $this->_options['options']); + $this->getTable()->setColumn($this->_options['name'], $this->_options['type'], $this->_options['length'], $this->_options['options']); if ($this->_options['unique'] == true && $this->_options['uniqueIndex'] == true && ! empty($this->_options['fields'])) { $indexFields = array($this->_options['name']); diff --git a/ipf/orm/template/timestampable.php b/ipf/orm/template/timestampable.php index 7c0c1fb..5c7c813 100644 --- a/ipf/orm/template/timestampable.php +++ b/ipf/orm/template/timestampable.php @@ -31,10 +31,10 @@ class IPF_ORM_Template_Timestampable extends IPF_ORM_Template public function setTableDefinition() { if (!$this->_options['created']['disabled']) { - $this->hasColumn($this->_options['created']['name'], $this->_options['created']['type'], null, $this->_options['created']['options']); + $this->getTable()->setColumn($this->_options['created']['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']); + $this->getTable()->setColumn($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