]> git.andy128k.dev Git - ipf-legacy-orm.git/commitdiff
cleanup
authorAndrey Kutejko <andy128k@gmail.com>
Sat, 27 Jul 2013 11:51:12 +0000 (14:51 +0300)
committerAndrey Kutejko <andy128k@gmail.com>
Sat, 27 Jul 2013 11:51:12 +0000 (14:51 +0300)
ipf/orm/connection.php
ipf/orm/export.php
ipf/orm/export/mysql.php
ipf/orm/formatter.php

index 0acb3f5970c314c8bb8aa09c95b50c07087292e9..b134b758a43cc76ec766cef59b9df1382f1ada82 100644 (file)
@@ -13,7 +13,6 @@ abstract class IPF_ORM_Connection extends IPF_ORM_Configurable implements Counta
     private $modules = array('transaction' => false,
                              'expression'  => false,
                              'export'      => false,
-                             'import'      => false,
                              'unitOfWork'  => false,
                              'formatter'   => false,
                              );
@@ -364,17 +363,20 @@ abstract class IPF_ORM_Connection extends IPF_ORM_Configurable implements Counta
         return $this->formatter->quoteIdentifier($str, $checkOption);
     }
     
-    public function quoteMultipleIdentifier($arr, $checkOption = true)
-    {
-        foreach ($arr as $k => $v) {
-            $arr[$k] = $this->quoteIdentifier($v, $checkOption);
-        }
-        return $arr;
-    }
-
     public function convertBooleans($item)
     {
-        return $this->formatter->convertBooleans($item);
+        if (is_array($item)) {
+            foreach ($item as $k => $value) {
+                if (is_bool($value)) {
+                    $item[$k] = (int) $value;
+                }
+            }
+        } else {
+            if (is_bool($item)) {
+                $item = (int) $item;
+            }
+        }
+        return $item;
     }
 
     public function quote($input, $type = null)
index 18b7c94cdd41270ce23b8c179182f42f9744eee8..a6d1ef6e30d589def4f26386b6568ce8afec5ebd 100644 (file)
@@ -95,7 +95,7 @@ class IPF_ORM_Export extends IPF_ORM_Connection_Module
             }
         }
 
-        $query = 'CREATE TABLE ' . $this->conn->quoteIdentifier($name, true) . ' (' . $queryFields;
+        $query = 'CREATE TABLE ' . $this->conn->quoteIdentifier($name) . ' (' . $queryFields;
         
         $check = $this->getCheckDeclaration($fields);
 
@@ -139,7 +139,7 @@ class IPF_ORM_Export extends IPF_ORM_Connection_Module
 
         $fields = array();
         foreach (array_keys($definition['fields']) as $field) {
-            $fields[] = $this->conn->quoteIdentifier($field, true);
+            $fields[] = $this->conn->quoteIdentifier($field);
         }
         $query .= ' ('. implode(', ', $fields) . ')';
 
index 4f61697c9d0980e423ae834ec19236746a00143c..27d6edbea4f260d1f320ff196591eec2bffe1d3b 100644 (file)
@@ -4,7 +4,7 @@ class IPF_ORM_Export_Mysql extends IPF_ORM_Export
 {
     public function createDatabaseSql($name)
     {
-        return 'CREATE DATABASE ' . $this->conn->quoteIdentifier($name, true);
+        return 'CREATE DATABASE ' . $this->conn->quoteIdentifier($name);
     }
 
     public function dropDatabaseSql($name)
@@ -70,7 +70,7 @@ class IPF_ORM_Export_Mysql extends IPF_ORM_Export
             $queryFields .= ', PRIMARY KEY(' . implode(', ', $keyColumns) . ')';
         }
 
-        $query = 'CREATE TABLE ' . $this->conn->quoteIdentifier($name, true) . ' (' . $queryFields . ')';
+        $query = 'CREATE TABLE ' . $this->conn->quoteIdentifier($name) . ' (' . $queryFields . ')';
 
         $optionStrings = array();
 
@@ -115,7 +115,7 @@ class IPF_ORM_Export_Mysql extends IPF_ORM_Export
 
     public function getDeclaration($name, array $field)
     {
-        $declaration = $this->conn->quoteIdentifier($name, true) . ' ';
+        $declaration = $this->conn->quoteIdentifier($name) . ' ';
 
         if (!isset($field['type']))
             throw new IPF_ORM_Exception('Missing column type.');
@@ -357,7 +357,7 @@ class IPF_ORM_Export_Mysql extends IPF_ORM_Export
                 } else {
                     $oldFieldName = $fieldName;
                 }
-                $oldFieldName = $this->conn->quoteIdentifier($oldFieldName, true);
+                $oldFieldName = $this->conn->quoteIdentifier($oldFieldName);
                 $query .= 'CHANGE ' . $oldFieldName . ' ' 
                         . $this->getDeclaration($fieldName, $field['definition']);
             }
@@ -369,7 +369,7 @@ class IPF_ORM_Export_Mysql extends IPF_ORM_Export
                     $query.= ', ';
                 }
                 $field = $changes['rename'][$renamedField];
-                $renamedField = $this->conn->quoteIdentifier($renamedField, true);
+                $renamedField = $this->conn->quoteIdentifier($renamedField);
                 $query .= 'CHANGE ' . $renamedField . ' '
                         . $this->getDeclaration($field['name'], $field['definition']);
             }
@@ -379,7 +379,7 @@ class IPF_ORM_Export_Mysql extends IPF_ORM_Export
             return false;
         }
 
-        $name = $this->conn->quoteIdentifier($name, true);
+        $name = $this->conn->quoteIdentifier($name);
         
         return 'ALTER TABLE ' . $name . ' ' . $query;
     }
@@ -483,14 +483,14 @@ class IPF_ORM_Export_Mysql extends IPF_ORM_Export
 
     public function dropIndexSql($table, $name)
     {
-        $table  = $this->conn->quoteIdentifier($table, true);
-        $name   = $this->conn->quoteIdentifier($this->conn->formatter->getIndexName($name), true);
+        $table  = $this->conn->quoteIdentifier($table);
+        $name   = $this->conn->quoteIdentifier($this->conn->formatter->getIndexName($name));
         return 'DROP INDEX ' . $name . ' ON ' . $table;
     }
 
     public function dropTableSql($table)
     {
-        $table  = $this->conn->quoteIdentifier($table, true);
+        $table  = $this->conn->quoteIdentifier($table);
         return 'DROP TABLE ' . $table;
     }
 
index 456fb2aa15f5cebe14398a455ef341804f35b60d..3b98fca0c73e2056939e702b2f3031ad8e7cd354 100644 (file)
@@ -19,22 +19,6 @@ class IPF_ORM_Formatter extends IPF_ORM_Connection_Module
         return $text;
     }
 
-    public function convertBooleans($item)
-    {
-        if (is_array($item)) {
-            foreach ($item as $k => $value) {
-                if (is_bool($value)) {
-                    $item[$k] = (int) $value;
-                }
-            }
-        } else {
-            if (is_bool($item)) {
-                $item = (int) $item;
-            }
-        }
-        return $item;
-    }
-
     public function quoteIdentifier($str, $checkOption = true)
     {
         if ($checkOption && ! $this->conn->getAttribute(IPF_ORM::ATTR_QUOTE_IDENTIFIER)) {
@@ -48,15 +32,6 @@ class IPF_ORM_Formatter extends IPF_ORM_Connection_Module
         return $tmp['start'] . $str . $tmp['end'];
     }
     
-    public function quoteMultipleIdentifier($arr, $checkOption = true)
-    {
-        foreach ($arr as $k => $v) {
-            $arr[$k] = $this->quoteIdentifier($v, $checkOption);
-        }
-
-        return $arr;
-    }
-
     public function quote($input, $type = null)
     {
         if ($type == null) {
@@ -89,16 +64,6 @@ class IPF_ORM_Formatter extends IPF_ORM_Connection_Module
         }
     }
 
-    public function fixIndexName($idx)
-    {
-        $indexPattern   = '/^'.preg_replace('/%s/', '([a-z0-9_]+)', $this->conn->getAttribute(IPF_ORM::ATTR_IDXNAME_FORMAT)).'$/i';
-        $indexName      = preg_replace($indexPattern, '\\1', $idx);
-        if ($indexName && ! strcasecmp($idx, $this->getIndexName($indexName))) {
-            return $indexName;
-        }
-        return $idx;
-    }
-
     public function getIndexName($idx)
     {
         return sprintf($this->conn->getAttribute(IPF_ORM::ATTR_IDXNAME_FORMAT),