Selaa lähdekoodia

Fixed: like 和 where条件冲突

Zhu Jinhui 6 vuotta sitten
vanhempi
commit
d17c9168a6
2 muutettua tiedostoa jossa 10 lisäystä ja 3 poistoa
  1. 10 2
      src/Driver/Base.php
  2. 0 1
      src/Router/Parse/Normal.php

+ 10 - 2
src/Driver/Base.php

@@ -645,7 +645,11 @@ class Base
 		if(count($likeArray) > 0)
 		{
 			$likeSQL = join(" OR ", $likeArray);
-			$this->where = sprintf($this->_query["WHERE"], $likeSQL);
+            if(!$this->where) {
+                $this->where = sprintf($this->_query["WHERE"], $likeSQL);
+            } else {
+                $this->where .=  ' AND ('. $likeSQL .')';
+            }
 		}
 		return $this;
 	}
@@ -665,7 +669,11 @@ class Base
 			}
 			if (sizeof($whereArray) > 0) {
 				$whereSQL = join(" AND ", $whereArray);
-				$this->where = sprintf($this->_query["WHERE"], $whereSQL);
+				if(!$this->where) {
+                    $this->where = sprintf($this->_query["WHERE"], $whereSQL);
+                }else{
+                    $this->where .= " AND (". $whereSQL .")";
+                }
 			}
 		}
 		return $this;

+ 0 - 1
src/Router/Parse/Normal.php

@@ -86,7 +86,6 @@ class Normal
         $match = ['url' => $url, 'controller' => $controller, 'action' => $action, 'dirInfo' => $dirInfo];
         if(isset($this->config['*:*'])) {
             list($controller, $action) = $arr = explode(':', $this->config['*:*']);
-
             preg_match_all("/\{[\d]{1,}\}|[\*]{1}/", $this->config['*:*'], $rules);
             if(!$rules) {
                 $match['match'] = '*:*';