]> git.andy128k.dev Git - ipf-legacy-orm.git/commitdiff
refactor adding columns
authorAndrey Kutejko <andy128k@gmail.com>
Sat, 27 Jul 2013 15:47:52 +0000 (18:47 +0300)
committerAndrey Kutejko <andy128k@gmail.com>
Sat, 27 Jul 2013 15:47:52 +0000 (18:47 +0300)
ipf/orm/import/builder.php
ipf/orm/record/abstract.php
ipf/orm/template/orderable.php
ipf/orm/template/owned.php
ipf/orm/template/sluggable.php
ipf/orm/template/timestampable.php

index b0633a9329504eeaba3679218e79b834ddbf7775..8258b5da4347ee25a3092aa7973cc6aec9092411 100644 (file)
@@ -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']))
index f34c98cd2b067b9db286f37632d1023a0c2d5335..41fd7f7a3aef32378044ffef6bd3429a12bd0d33 100644 (file)
@@ -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);
index 3d82df9cb6cdfa9fe5b1a1b80a4c94eb6230fed9..34a4d7429b97a2f8fd1015e9c53d0e80fe904307 100644 (file)
@@ -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);
     }
index dbe2a964e1d82368f47768a680b593625a354714..db204c0f63fd6b2bd4f6497e7a24d1db7d4dce70 100644 (file)
@@ -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,
         ));
index 35e5700b6aa5a9b440449ac4862a51ca871983ed..a73d12002fac7247fa423ceabeee64d15f29ec88 100644 (file)
@@ -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']);
index 7c0c1fb62f31756ee4f6ec5b04d0a74fc530dcd3..5c7c813c8d666e643a4ffb8c9c279d900a06ee35 100644 (file)
@@ -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);
     }