stanley-king 1 год назад
Родитель
Сommit
58ba71feb6

+ 4 - 1
core/framework/db/comysqli.php

@@ -141,7 +141,10 @@ class Db
 
                 if ($eno == self::ErrUnConnect) {
                     if ($count > 0) return false;
-                    $link = self::connect($link,$host);
+
+                    $link = self::connect($link,'master');
+                    $link = self::connect($link,'slave');
+
                     CoMysqliPool::instance()->reset(Co::getCid(),$link);
                     $count++;
                 }

+ 15 - 7
core/framework/db/mysqli.php

@@ -124,25 +124,33 @@ class Db
             {
                 $eno = mysqli_errno(self::$link[$host]);
                 $emsg = mysqli_error(self::$link[$host]);
-                $error = "DbError eno={$eno} msg={$emsg}";
-                Log::record("{$error} sql={$sql}", Log::ERR);
+
+                $error = "DbError eno=$eno host=$host msg=$emsg sql=$sql";
+                Log::record($error, Log::ERR);
 
                 if(self::$trans_layers > 0) {
                     throw new Exception($error);
                 }
 
-                if ($eno == self::ErrUnConnect) {
+                if ($eno == self::ErrUnConnect)
+                {
                     if ($count > 0) return false;
-                    self::connect($host);
+
+                    self::connect('master');
+                    self::connect('slave');
+
                     $count++;
-                } elseif (C('debug')) {
+                }
+                elseif (C('debug')) {
                     throw_exception($error . '<br/>' . $sql);
                     return false;
-                } elseif (self::ping($host) == false) {
+                }
+                elseif (self::ping($host) == false) {
                     if ($count > 0) return false;
                     self::connect($host);
                     $count++;
-                } else {
+                }
+                else {
                     return false;
                 }
             }

+ 2 - 2
core/framework/function/core.php

@@ -479,8 +479,8 @@ function Model($model = null, $base_path = null)
         }
 
         $base_path = $base_path == null ? BASE_DATA_PATH : $base_path;
-        $file_name = $base_path.'/model/'.$model.'.model.php';
-        $class_name = $model.'Model';
+        $file_name = $base_path . '/model/' . $model . '.model.php';
+        $class_name = $model . 'Model';
 
         if (!file_exists($file_name)){
             $_cache[$cache_key] =  new Model($model);

+ 5 - 6
helper/refill/RefillBase.php

@@ -478,7 +478,7 @@ class RefillBase
         if ($mch_amount > $available) {
             $errmsg = "余额不足=$available";
             Log::record($errmsg, Log::DEBUG);
-            return [errcode::MERCHANT_SHORT_MONEY, $errmsg,$last_orderid,false,0];
+            return [errcode::MERCHANT_SHORT_MONEY, $errmsg, $last_orderid, false, 0];
         }
 
         foreach ($providers as $provider)
@@ -514,7 +514,6 @@ class RefillBase
                 else {
                     continue;
                 }
-
             }
 
             $mod_refill = Model('refill_order');
@@ -677,7 +676,7 @@ class RefillBase
                 $fSuccess = $refill_creater($order, $last_orderid, $order_id, $order_sn, $mod_refill);
 
                 if(!$fSuccess) {
-                    Log::record("refill_creater fail:order_sn={$order_sn}",Log::ERR);
+                    Log::record("refill_creater fail: order_sn=$order_sn", Log::ERR);
                     $order_canceler($order_id,'refill_order 记录创建失败');
                     return [false, $order_id, $order_sn];
                 }
@@ -688,18 +687,18 @@ class RefillBase
                 }
 
                 Log::record(sprintf(__METHOD__ . " request time=%.6f", microtime(true) - $start), Log::DEBUG);
-                return [true,$order_id,$order_sn];
+                return [true, $order_id, $order_sn];
             }
             else
             {
                 Log::record(__METHOD__ . " fail:buyStep3 err msg={$result['msg']}", Log::ERR);
-                return [false,0,''];
+                return [false, 0, ''];
             }
         }
         catch (Exception $ex)
         {
             Log::record($ex->getMessage(), Log::ERR);
-            return [false,0,''];
+            return [false, 0, ''];
         }
     }