From: Andrey Kutejko Date: Sat, 27 Jul 2013 11:51:12 +0000 (+0300) Subject: cleanup X-Git-Tag: 0.5~134 X-Git-Url: https://git.andy128k.dev/?a=commitdiff_plain;h=135c037e3c2886d89e46537f230e86d757c50c31;p=ipf.git cleanup --- diff --git a/ipf/orm/connection.php b/ipf/orm/connection.php index 0acb3f5..b134b75 100644 --- a/ipf/orm/connection.php +++ b/ipf/orm/connection.php @@ -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) diff --git a/ipf/orm/export.php b/ipf/orm/export.php index 18b7c94..a6d1ef6 100644 --- a/ipf/orm/export.php +++ b/ipf/orm/export.php @@ -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) . ')'; diff --git a/ipf/orm/export/mysql.php b/ipf/orm/export/mysql.php index 4f61697..27d6edb 100644 --- a/ipf/orm/export/mysql.php +++ b/ipf/orm/export/mysql.php @@ -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; } diff --git a/ipf/orm/formatter.php b/ipf/orm/formatter.php index 456fb2a..3b98fca 100644 --- a/ipf/orm/formatter.php +++ b/ipf/orm/formatter.php @@ -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),