From 7e365df043b09409db2b0c3ae38966fe526dfc97 Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Sat, 15 Sep 2018 00:46:59 +0100 Subject: [PATCH] lib/php/db/field.php --- lib/php/db/field.php | 16 ++++++++++++++-- lib/php/db/table.php | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/php/db/field.php b/lib/php/db/field.php index 94184c7f..d59a6219 100644 --- a/lib/php/db/field.php +++ b/lib/php/db/field.php @@ -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'; } diff --git a/lib/php/db/table.php b/lib/php/db/table.php index 4da49e76..29726eb3 100644 --- a/lib/php/db/table.php +++ b/lib/php/db/table.php @@ -634,7 +634,7 @@ Class Table extends nb { echo '' .'
' - .( empty($_SERVER['HTTP_REFERER']) ? '' : '') + .( empty($_SERVER['HTTP_REFERER']) ? '' : '') .'' .'' .'
'.NB_EOL -- 2.47.3