]> git.andy128k.dev Git - ipf.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)
14 files changed:
ipf/admin/models/_generated/BaseAdminLog.php
ipf/auth/models/_generated/BasePermission.php
ipf/auth/models/_generated/BaseRole.php
ipf/auth/models/_generated/BaseRolePermission.php
ipf/auth/models/_generated/BaseUser.php
ipf/auth/models/_generated/BaseUserPermission.php
ipf/auth/models/_generated/BaseUserRole.php
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
ipf/session/models/_generated/BaseSession.php

index 1c6aa575704d7d53cf5bb0268e3ff102bf46b249..a76d24c0cca2720d91a63cd04b11d2b0e418ca11 100644 (file)
@@ -11,13 +11,13 @@ abstract class BaseAdminLog extends IPF_ORM_Record
   public function setTableDefinition()
   {
     $this->setTableName('admin_log');
-    $this->hasColumn('username', 'string', 32, array('type' => 'string', 'length' => '32'));
-    $this->hasColumn('user_id', 'integer', null, array('type' => 'integer'));
-    $this->hasColumn('object_id', 'integer', null, array('type' => 'integer'));
-    $this->hasColumn('object_class', 'string', 200, array('type' => 'string', 'length' => '200'));
-    $this->hasColumn('object_repr', 'string', 200, array('type' => 'string', 'length' => '200'));
-    $this->hasColumn('action_flag', 'integer', null, array('type' => 'integer'));
-    $this->hasColumn('change_message', 'string', 200, array('type' => 'string', 'length' => '200'));
+    $this->getTable()->setColumn('username', 'string', 32, array('type' => 'string', 'length' => '32'));
+    $this->getTable()->setColumn('user_id', 'integer', null, array('type' => 'integer'));
+    $this->getTable()->setColumn('object_id', 'integer', null, array('type' => 'integer'));
+    $this->getTable()->setColumn('object_class', 'string', 200, array('type' => 'string', 'length' => '200'));
+    $this->getTable()->setColumn('object_repr', 'string', 200, array('type' => 'string', 'length' => '200'));
+    $this->getTable()->setColumn('action_flag', 'integer', null, array('type' => 'integer'));
+    $this->getTable()->setColumn('change_message', 'string', 200, array('type' => 'string', 'length' => '200'));
     $this->index('idx_object_id', array('fields' => 'object_id'));
     $this->index('idx_object_class', array('fields' => 'object_class'));
     $this->index('idx_created_at', array('fields' => 'created_at'));
index 351ce329569532671e1962b59f2d6dd710fb7bb1..69c7648ada4b394325fc50683c47be21a84e31ae 100644 (file)
@@ -11,7 +11,7 @@ abstract class BasePermission extends IPF_ORM_Record
   public function setTableDefinition()
   {
     $this->setTableName('auth_permission');
-    $this->hasColumn('name', 'string', 255, array('unique' => true, 'type' => 'string', 'length' => '255'));
+    $this->getTable()->setColumn('name', 'string', 255, array('unique' => true, 'type' => 'string', 'length' => '255'));
     $this->option('type', 'INNODB');
     $this->option('collate', 'utf8_unicode_ci');
     $this->option('charset', 'utf8');
index 8eef3477461380fdfa639b361e5acbb08c96010d..e9bdf4cc41680c1811ce5f89730555cd1c46fe2b 100644 (file)
@@ -11,7 +11,7 @@ abstract class BaseRole extends IPF_ORM_Record
   public function setTableDefinition()
   {
     $this->setTableName('auth_role');
-    $this->hasColumn('name', 'string', 255, array('unique' => true, 'type' => 'string', 'notblank' => true, 'length' => '255'));
+    $this->getTable()->setColumn('name', 'string', 255, array('unique' => true, 'type' => 'string', 'notblank' => true, 'length' => '255'));
     $this->option('type', 'INNODB');
     $this->option('collate', 'utf8_unicode_ci');
     $this->option('charset', 'utf8');
index 084fed076f283465fdcad1ab1f35f84976cdd723..bdf64c51f11c68299e0409a29d445bca4be0636e 100644 (file)
@@ -11,8 +11,8 @@ abstract class BaseRolePermission extends IPF_ORM_Record
   public function setTableDefinition()
   {
     $this->setTableName('auth_role_permission');
-    $this->hasColumn('role_id', 'integer', null, array('type' => 'integer', 'primary' => true));
-    $this->hasColumn('permission_id', 'integer', null, array('type' => 'integer', 'primary' => true));
+    $this->getTable()->setColumn('role_id', 'integer', null, array('type' => 'integer', 'primary' => true));
+    $this->getTable()->setColumn('permission_id', 'integer', null, array('type' => 'integer', 'primary' => true));
     $this->option('type', 'INNODB');
     $this->option('collate', 'utf8_unicode_ci');
     $this->option('charset', 'utf8');
index 7213eeb3aa0a1d72335dfebb454629a8db98b788..ba17448bc5a2f48553349caf510d9f992580f58e 100644 (file)
@@ -11,15 +11,15 @@ abstract class BaseUser extends IPF_ORM_Record
   public function setTableDefinition()
   {
     $this->setTableName('auth_user');
-    $this->hasColumn('username', 'string', 32, array('type' => 'string', 'notblank' => true, 'notnull' => true, 'unique' => true, 'length' => '32'));
-    $this->hasColumn('password', 'string', 128, array('type' => 'string', 'notblank' => true, 'notnull' => true, 'length' => '128'));
-    $this->hasColumn('first_name', 'string', 32, array('type' => 'string', 'length' => '32'));
-    $this->hasColumn('last_name', 'string', 32, array('type' => 'string', 'length' => '32'));
-    $this->hasColumn('email', 'string', 200, array('type' => 'string', 'email' => true, 'notnull' => true, 'notblank' => true, 'unique' => true, 'length' => '200'));
-    $this->hasColumn('is_staff', 'boolean', null, array('type' => 'boolean', 'notnull' => true, 'default' => false));
-    $this->hasColumn('is_active', 'boolean', null, array('type' => 'boolean', 'notnull' => true, 'default' => false));
-    $this->hasColumn('is_superuser', 'boolean', null, array('type' => 'boolean', 'notnull' => true, 'default' => false));
-    $this->hasColumn('last_login', 'timestamp', null, array('type' => 'timestamp'));
+    $this->getTable()->setColumn('username', 'string', 32, array('type' => 'string', 'notblank' => true, 'notnull' => true, 'unique' => true, 'length' => '32'));
+    $this->getTable()->setColumn('password', 'string', 128, array('type' => 'string', 'notblank' => true, 'notnull' => true, 'length' => '128'));
+    $this->getTable()->setColumn('first_name', 'string', 32, array('type' => 'string', 'length' => '32'));
+    $this->getTable()->setColumn('last_name', 'string', 32, array('type' => 'string', 'length' => '32'));
+    $this->getTable()->setColumn('email', 'string', 200, array('type' => 'string', 'email' => true, 'notnull' => true, 'notblank' => true, 'unique' => true, 'length' => '200'));
+    $this->getTable()->setColumn('is_staff', 'boolean', null, array('type' => 'boolean', 'notnull' => true, 'default' => false));
+    $this->getTable()->setColumn('is_active', 'boolean', null, array('type' => 'boolean', 'notnull' => true, 'default' => false));
+    $this->getTable()->setColumn('is_superuser', 'boolean', null, array('type' => 'boolean', 'notnull' => true, 'default' => false));
+    $this->getTable()->setColumn('last_login', 'timestamp', null, array('type' => 'timestamp'));
     $this->option('type', 'INNODB');
     $this->option('collate', 'utf8_unicode_ci');
     $this->option('charset', 'utf8');
index 9cfd2e3f5424e29e19aff2c8237fbe395497214f..227ed05198d75313540568c3e8a392f5fdf7ef7f 100644 (file)
@@ -11,8 +11,8 @@ abstract class BaseUserPermission extends IPF_ORM_Record
   public function setTableDefinition()
   {
     $this->setTableName('auth_user_permission');
-    $this->hasColumn('user_id', 'integer', null, array('type' => 'integer', 'primary' => true));
-    $this->hasColumn('permission_id', 'integer', null, array('type' => 'integer', 'primary' => true));
+    $this->getTable()->setColumn('user_id', 'integer', null, array('type' => 'integer', 'primary' => true));
+    $this->getTable()->setColumn('permission_id', 'integer', null, array('type' => 'integer', 'primary' => true));
     $this->option('type', 'INNODB');
     $this->option('collate', 'utf8_unicode_ci');
     $this->option('charset', 'utf8');
index 24d47329722bf97de0f4438450d88bfb77d3e9a9..ab9b2ddf85d7ad5f7f051799bf55be551cc1ba94 100644 (file)
@@ -11,8 +11,8 @@ abstract class BaseUserRole extends IPF_ORM_Record
   public function setTableDefinition()
   {
     $this->setTableName('auth_user_role');
-    $this->hasColumn('user_id', 'integer', null, array('type' => 'integer', 'primary' => true));
-    $this->hasColumn('role_id', 'integer', null, array('type' => 'integer', 'primary' => true));
+    $this->getTable()->setColumn('user_id', 'integer', null, array('type' => 'integer', 'primary' => true));
+    $this->getTable()->setColumn('role_id', 'integer', null, array('type' => 'integer', 'primary' => true));
     $this->option('type', 'INNODB');
     $this->option('collate', 'utf8_unicode_ci');
     $this->option('charset', 'utf8');
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);
     }
index 760b01a595c78fa54c492e892ecf2971767a0141..242e682808b1ba2cd6b7efd0b0ca2404e9eb1552 100644 (file)
@@ -11,9 +11,9 @@ abstract class BaseSession extends IPF_ORM_Record
   public function setTableDefinition()
   {
     $this->setTableName('session');
-    $this->hasColumn('session_key', 'string', 40, array('primary' => true, 'type' => 'string', 'length' => '40'));
-    $this->hasColumn('session_data', 'string', null, array('type' => 'string'));
-    $this->hasColumn('expire_data', 'timestamp', null, array('type' => 'timestamp'));
+    $this->getTable()->setColumn('session_key', 'string', 40, array('primary' => true, 'type' => 'string', 'length' => '40'));
+    $this->getTable()->setColumn('session_data', 'string', null, array('type' => 'string'));
+    $this->getTable()->setColumn('expire_data', 'timestamp', null, array('type' => 'timestamp'));
   }