]> git.nbdom.net Git - nb.git/commitdiff
lib/php/db/field.php
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Fri, 14 Sep 2018 23:46:59 +0000 (00:46 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Fri, 14 Sep 2018 23:46:59 +0000 (00:46 +0100)
lib/php/db/field.php
lib/php/db/table.php

index 94184c7ff69184d16403a148f5f1fcd91436b49e..d59a621919ecfd549e30b585d66fdc4c55374edf 100644 (file)
@@ -83,7 +83,13 @@ class field extends nb {
     if (strpos($this->type,'date') !== false) return 'date';
   }
 
+# NB 14.09.18   public function sqlValue($value) {
+# NB 14.09.18     if (strpos($this->type,'bool') !== false) return preg_match('/^(f.*|no|0)?\s*$/i',$value) ? false : true;
+# NB 14.09.18          return $value;
+# NB 14.09.18  }
+
   public function htmlValue($value,&$mime=null) {
+    #if (strpos($this->type,'bool') !== false) re
 
     if (strpos($this->type,'bool') !== false) {
       return preg_match('/^(1|yes|on|true)/i',$value) ? 'Yes' : 'No';
@@ -266,7 +272,9 @@ class field extends nb {
   public function quote($value,$force_quote=false) {
 
     if ($value === null) return 'NULL';
+
     if ($force_quote or $this->string()) {
+
       if ($value === '') {
         if (strpos($this->type,'time') !== false) return 'NULL';
         if (strpos($this->type,'date') !== false) return 'NULL';
@@ -274,10 +282,14 @@ class field extends nb {
 
       if (!($db = $this->db())) return "'".str_replace("'","''",$value)."'";
 
-      if ($fct=$db->conf_type('quote_field')) return $fct($value);
+      if ($fct = $db->conf_type('quote_field')) return $fct($value);
+
       return $db->quote($value);
 
-    } else {
+    } else { # Not a string
+
+                       # NB 14.09.18: Ok with all databases types ? 
+       if (strpos($this->type,'bool') !== false) $value = preg_match('/^(f.*|no|0)?\s*$/i',$value) ? 'false' : 'true';
 
       if (strcmp($value,'') == 0) $value = 'NULL';
     }
index 4da49e768862c8fcfab849bd15f14db087a0e81c..29726eb339e84ff333b6c1801d140b2ba1a5f1cc 100644 (file)
@@ -634,7 +634,7 @@ Class Table extends nb {
 
                echo ''
                        .'<div class="db buttons">'
-                       .( empty($_SERVER['HTTP_REFERER']) ? '' : '<input type="button btn btn-danger" onclick="document.location=document.referrer" value="Cancel" />')
+                       .( empty($_SERVER['HTTP_REFERER']) ? '' : '<input type="button" class="btn btn-danger" onclick="document.location=document.referrer" value="Cancel" />')
                        .'<input class="btn btn-warning" type="reset" />'
                        .'<input class="btn btn-success" type="submit" />'
                        .'</div>'.NB_EOL