]> git.andy128k.dev Git - ipf-legacy-orm.git/commitdiff
rework value quoting
authorAndrey Kutejko <andy128k@gmail.com>
Sat, 27 Jul 2013 12:24:34 +0000 (15:24 +0300)
committerAndrey Kutejko <andy128k@gmail.com>
Sat, 27 Jul 2013 12:24:34 +0000 (15:24 +0300)
ipf/orm/connection.php
ipf/orm/formatter.php

index 9bb9f1001f32c109c2465fd3c7c80855549a83a3..6e1fe6a0d3f95f99ee2534a5d12250a16c79ae38 100644 (file)
@@ -369,9 +369,38 @@ abstract class IPF_ORM_Connection extends IPF_ORM_Configurable implements Counta
         return $item;
     }
 
-    public function quote($input, $type = null)
-    {
-        return $this->formatter->quote($input, $type);
+    public function quote($input, $type=null)
+    {
+        if ($type === null)
+            $type = gettype($input);
+
+        switch ($type) {
+            case 'integer':
+            case 'enum':
+            case 'boolean':
+            case 'double':
+            case 'float':
+            case 'bool':
+            case 'decimal':
+            case 'int':
+                return $input;
+            case 'array':
+            case 'object':
+                $input = serialize($input);
+            case 'date':
+            case 'time':
+            case 'timestamp':
+            case 'string':
+            case 'char':
+            case 'varchar':
+            case 'text':
+            case 'gzip':
+            case 'blob':
+            case 'clob':
+                return $this->getDbh()->quote($input);
+            default:
+                throw new IPF_ORM_Exception('Unsupported type \''.$type.'\'.');
+        }
     }
 
     public function setDateFormat($format = null)
index 3e448482fbe2aa8b3bbbafb2f0fe37cc65f68b55..c61eb4d10ebbe01ed0b385af1c12104ab3428c9a 100644 (file)
@@ -19,38 +19,6 @@ class IPF_ORM_Formatter extends IPF_ORM_Connection_Module
         return $text;
     }
 
-    public function quote($input, $type = null)
-    {
-        if ($type == null) {
-            $type = gettype($input);
-        }
-        switch ($type) {
-        case 'integer':
-        case 'enum':
-        case 'boolean':
-        case 'double':
-        case 'float':
-        case 'bool':
-        case 'decimal':
-        case 'int':
-            return $input;
-        case 'array':
-        case 'object':
-            $input = serialize($input);
-        case 'date':
-        case 'time':
-        case 'timestamp':
-        case 'string':
-        case 'char':
-        case 'varchar':
-        case 'text':
-        case 'gzip':
-        case 'blob':
-        case 'clob':
-            return $this->conn->getDbh()->quote($input);
-        }
-    }
-
     public function getIndexName($idx)
     {
         return sprintf($this->conn->getAttribute(IPF_ORM::ATTR_IDXNAME_FORMAT),