]> git.nbdom.net Git - nb.git/commitdiff
field.quote for boolean, function string
authorNicolas Boisselier <nicolas.boisselier@semantico.com>
Thu, 27 Oct 2016 11:23:40 +0000 (12:23 +0100)
committerNicolas Boisselier <nicolas.boisselier@semantico.com>
Thu, 27 Oct 2016 11:23:40 +0000 (12:23 +0100)
lib/php/db/field.php

index 35cc575c3ef19bd13ce43d3cb8eb009a1c064e26..19ea29db075ec1f7f1c72bf40f9b147d1de91a1c 100644 (file)
@@ -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);