From: Nicolas Boisselier Date: Thu, 27 Oct 2016 11:23:40 +0000 (+0100) Subject: field.quote for boolean, function string X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=f321e45b4e5fb617022e8ddd71e5c44e1b0ae1bb;p=nb.git field.quote for boolean, function string --- diff --git a/lib/php/db/field.php b/lib/php/db/field.php index 35cc575c..19ea29db 100644 --- a/lib/php/db/field.php +++ b/lib/php/db/field.php @@ -44,6 +44,12 @@ class field extends nb { return $this->autoincrement; } + public function string() { + if ($this->numeric()) return false; + if (strpos($this->type,'bool') !== false) return false; + return true; + } + public function numeric() { return preg_match('/signed|(snall )?int|float|decimal|numeric|number|currency/i',$this->type) ? true : false; } @@ -161,7 +167,7 @@ class field extends nb { public function quote($value,$force_quote=false) { if ($value === null) return 'NULL'; - if ($force_quote or !$this->numeric()) { + if ($force_quote or $this->string()) { if (!($db = $this->db())) return "'".preg_replace("/'/","\\'",$value)."'"; return $db->quote($value);