From: Andrey Kutejko Date: Sat, 27 Jul 2013 12:24:34 +0000 (+0300) Subject: rework value quoting X-Git-Tag: 0.5~132 X-Git-Url: https://git.andy128k.dev/?a=commitdiff_plain;h=0e7a8aa8f001f0ec52ec01472d8c17901a3bdd53;p=ipf.git rework value quoting --- diff --git a/ipf/orm/connection.php b/ipf/orm/connection.php index 9bb9f10..6e1fe6a 100644 --- a/ipf/orm/connection.php +++ b/ipf/orm/connection.php @@ -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) diff --git a/ipf/orm/formatter.php b/ipf/orm/formatter.php index 3e44848..c61eb4d 100644 --- a/ipf/orm/formatter.php +++ b/ipf/orm/formatter.php @@ -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),