From: Nicolas Boisselier Date: Fri, 3 Aug 2018 09:55:48 +0000 (+0100) Subject: lib/php/db/table.php X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=86320163ae444caca0e7e37495ea3b6a373f882f;p=nb.git lib/php/db/table.php --- diff --git a/lib/php/db.php b/lib/php/db.php index 2f664eb5..cf120872 100644 --- a/lib/php/db.php +++ b/lib/php/db.php @@ -1387,6 +1387,12 @@ class Db extends nb { return $str; } + public function lower_if_case_sensitive($v,$db_fct = true) { + if (!$this->conf_type('like_nocase')) return $v; + if (!$db_fct) return strtolower($v); + return "LOWER($v)"; + } + public function like_nocase() { if ($v = $this->conf_type('like_nocase')) return $v; return 'LIKE'; diff --git a/lib/php/db/table.php b/lib/php/db/table.php index 3330e58e..8a60887a 100644 --- a/lib/php/db/table.php +++ b/lib/php/db/table.php @@ -814,6 +814,7 @@ Class Table extends nb { $v = substr($v,1); $v = $this->db()->quote($v); $equal = ' '.($not ? $regexp_not : '').$regexp.' '; + $v = $this->db()->lower_if_case_sensitive($v,false); } elseif ($field->string()) { @@ -825,12 +826,13 @@ Class Table extends nb { $v = $this->db()->quote($v); if (preg_match('/[_%]/',$v)) { $match = 'like'; -# NB 07.01.18 $equal = ' '.($not ? 'NOT ' : '').'LIKE '; $equal = ' '.($not ? 'NOT ' : '').$this->db()->like_nocase().' '; } else { $equal = ($not ? '<> ' : $equal); } + $v = $this->db()->lower_if_case_sensitive($v,false); + // Others } else { @@ -849,6 +851,7 @@ Class Table extends nb { } $name = $field->sql_name(true); + $name = $this->db()->lower_if_case_sensitive($name,true); if ($field->extras) { $k = $this->extras[$k]->sql_name();