Sfoglia il codice sorgente

Fixed:多个where条件条件合并预期不符

zjh 4 mesi fa
parent
commit
6e7a942dff

+ 4 - 1
src/Driver/Base.php

@@ -1101,8 +1101,11 @@ class Base
                 continue;
             }
             if(is_array($val)) {
+                // group array 的情况,每组条件之间加 and
                 $slices[] = $this->groupContents($val)[0];
-                //print_r($this->groupContents($val));
+                if($index < $count - 1) {
+                    $slices[] = 'and';
+                }
                 continue;
             }
             $isOperator = $this->isOperator($val);//如果是操作符,上一个不是操作符就清空tmpWhere,并放入slices

+ 6 - 5
src/Driver/Entity/Base.php

@@ -192,7 +192,7 @@ class Base {
     }
 
     /**
-     * where 条件
+     * where 条件 多个where就用and来连接
      * @param array $where where条件
      * @param mixed $args 参数
      * @return $this
@@ -200,11 +200,12 @@ class Base {
      */
     final public function where($where, $args = null) {
         $this->setWhereHooker(function($w) use($where){
-            if(is_array($where)) {
-                $w = array_merge($w, $where);
+            /*if(is_array($where)) {
+                $w[] = $where;
                 return $w;
-            }
-            return $where;
+            }*/
+            $w[] = $where;
+            return $w;
         }, $args);
         return $this;
     }

+ 7 - 6
src/Exceptions/Errors.php

@@ -61,12 +61,6 @@ class Errors extends \Exception
         if (\Qii::getInstance()->request == null) {
             \Qii::getInstance()->request = \Qii::getInstance()->getRequest();
         }
-        if (\Qii::getInstance()->request->getExtension() == 'json') {
-            $code = $e->getCode();
-            if ($code == 0) $code = 1;
-            echo json_encode(array('code' => $code, 'line' =>  self::getRelatePath($_SERVER['SCRIPT_FILENAME'], $e->getFile()) . ' line :' . $e->getLine(), 'msg' => strip_tags($e->getMessage())), JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_UNESCAPED_UNICODE);
-            return;
-        }
         $message[] = (IS_CLI ? QII_EOL : '') . \Qii::i('Error file', self::getRelatePath($_SERVER['SCRIPT_FILENAME'], $e->getFile())) . (IS_CLI ? QII_EOL : '');
         $message[] = \Qii::i('Error code', $e->getCode()) . (IS_CLI ? QII_EOL : '');
         $message[] = \Qii::i('Error description', $e->getMessage()) . (IS_CLI ? QII_EOL : '');
@@ -88,6 +82,7 @@ class Errors extends \Exception
         if ($env == 'product' || (isset($appConfigure['errorPage']) && $appConfigure['errorPage'] && (isset($appConfigure['debug']) && $appConfigure['debug'] == 0))) {
             list($controller, $action) = explode(':', $appConfigure['errorPage']);
             $controllerCls = $controller;
+
             if(substr($controller, 0, 1) != '\\') {
                 $controllerCls = Register::get(Consts::APP_DEFAULT_CONTROLLER_PREFIX) . '\\' . $controller;
             }
@@ -107,6 +102,12 @@ class Errors extends \Exception
             }
             return \Qii::getInstance()->dispatcher->setRequest(\Qii::getInstance()->request)->dispatch($controller, $action, $e);
         }
+        if (\Qii::getInstance()->request->getExtension() == 'json') {
+            $code = $e->getCode();
+            if ($code == 0) $code = 1;
+            echo json_encode(array('code' => $code, 'line' =>  self::getRelatePath($_SERVER['SCRIPT_FILENAME'], $e->getFile()) . ' line :' . $e->getLine(), 'msg' => strip_tags($e->getMessage())), JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_UNESCAPED_UNICODE);
+            return;
+        }
         ob_start();
         include(join(DS, array(QII_DIR, 'Exceptions', 'View', 'error.php')));
         $html = ob_get_contents();

+ 3 - 0
src/Library/Third/Curl/Curl.php

@@ -954,6 +954,9 @@ class Curl
     public function setHeaders($headers)
     {
         foreach ($headers as $key => $value) {
+            if(is_array($value)) {
+                $value = join(', ', $value);
+            }
             $this->headers[$key] = $value;
         }