]> git.nbdom.net Git - nb.git/commitdiff
Fix bugs
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Wed, 6 Apr 2016 11:41:42 +0000 (13:41 +0200)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Wed, 6 Apr 2016 11:41:42 +0000 (13:41 +0200)
lib/php/db/table.php
lib/php/db/types/sqlite.php

index 2f0e2ba914d7a63b34f980919f28220eb5c94558..c81045927797a82e512bafc9ea8973a9db109c5d 100644 (file)
@@ -460,7 +460,11 @@ Class Table extends nb {
         $v = str_replace('*','%',$v);
 
         $v = $this->db()->quote($v);
-        $equal = ' '.($not ? 'NOT ' : '').'LIKE ';
+        if (preg_match('/[_%]/',$v)) {
+          $equal = ' '.($not ? 'NOT ' : '').'LIKE ';
+        } else {
+          $equal = ($not ? '<> ' : '=');
+        }
 
       // Others
       } else {
@@ -485,13 +489,15 @@ Class Table extends nb {
       # having, denorm, EMPTY
       $extra_where = (string)$this->db()->type('extra_where');
       if ($extra_where == 'having' and $field->extra) {
-        $having[] = "$k$equal$v";
+        $having[] = $this->extras[$k]->sql_name()."$equal$v";
 
       } elseif ($extra_where == 'denorm' and $field->extra) {
         $where[] = $this->extras[$k]->sql_name()."$equal$v";
 
+      } elseif ($field->extra) {
+        $where[] = $this->extras[$k]->sql_name()."$equal$v";
       } else {
-        $where[] = "$k$equal$v";
+        $where[] = $field->sql_name()."$equal$v";
       }
 
     } #foreach fields
@@ -695,6 +701,7 @@ Class Table extends nb {
 
     if ($out_conf) {
       out::end($out_conf);
+
     } else {
       echo $this->{"rows_end_$format"}();
 
index bab403e53b4da5a1316fec3083d2e8b85bf8ae3c..e0d9c276c2b51a62561d8b4d1c06c8eadc88c03d 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 $DB_TYPES['sqlite'] = array (
 'use_path' => true,
+'extra_where' => 'denorm',
 
 'quote_name' => '`',