Max F 5 vuotta sitten
vanhempi
commit
87207b4adc
2 muutettua tiedostoa jossa 18 lisäystä ja 5 poistoa
  1. 2 2
      src/Database/Sql/SqlDb.php
  2. 16 3
      src/Database/Sql/SqlTools.php

+ 2 - 2
src/Database/Sql/SqlDb.php

@@ -276,9 +276,9 @@ class SqlDb
 	}
 
 
-	public function buildSqlWhereSearch($q='', $search_fields=[])
+	public function buildSqlWhereSearch($q='', $search_fields=[], $min_str_length=1, $max_words=10, $all_words_required=false)
 	{
-		return $this->tools->buildSqlWhereSearch($q, $search_fields);
+		return $this->tools->buildSqlWhereSearch($q, $search_fields, $min_str_length, $max_words, $all_words_required);
 	}
 
 

+ 16 - 3
src/Database/Sql/SqlTools.php

@@ -215,12 +215,17 @@ class SqlTools
 
 
 
-    public function buildSqlWhereSearch($q='', $search_fields=[], $min_str_length=1, $max_words=10)
+    public function buildSqlWhereSearch($q='', $search_fields=[], $min_str_length=1, $max_words=10, $all_words_required=false)
     {
         $db = $this->db;
         
         $select_sum = "(0";
-        $search_where = "(0";
+
+        if ($all_words_required) {
+            $search_where = "(1";
+        } else {
+            $search_where = "(0";
+        }
 
         $q = trim($q);
         
@@ -243,7 +248,15 @@ class SqlTools
                 }
 
                 $word_condition = "(" . implode(" or ", $conditions_or) . ")";
-                $search_where .= " or " . $word_condition;
+
+                if ($all_words_required) {
+                    // TODO
+                    $search_where .= " and (" . $word_condition . ")";
+
+                } else {
+                    $search_where .= " or " . $word_condition;
+
+                }
 
 
                 //$select_sum .= " + if(" . $word_condition . ", " . $word_idx_score . ", 0)";