|
@@ -122,11 +122,12 @@ class Db
|
|
|
|
|
|
if ($query === false)
|
|
|
{
|
|
|
- $errno = mysqli_errno(self::$link[$host]);
|
|
|
- $error = "Db Error: no= error={$errno}" . mysqli_error(self::$link[$host]);
|
|
|
- Log::record($error."\r\n".$sql,Log::ERR);
|
|
|
+ $eno = mysqli_errno(self::$link[$host]);
|
|
|
+ $emsg = mysqli_error(self::$link[$host]);
|
|
|
+ $error = "Db Error eno={$eno} msg={$emsg}";
|
|
|
|
|
|
- if($errno == self::ErrUnConnect || $errno == self::ErrLock)
|
|
|
+ Log::record("{$error} \r\n sql={$sql}",Log::ERR);
|
|
|
+ if($eno == self::ErrUnConnect || $eno == self::ErrLock)
|
|
|
{
|
|
|
if($count > 0) return false;
|
|
|
self::closeLink($host);
|
|
@@ -623,6 +624,7 @@ class Db
|
|
|
self::closeLink($host);
|
|
|
self::connect($host);
|
|
|
}
|
|
|
+ Log::record("autocommit start",Log::DEBUG);
|
|
|
self::$link[$host]->autocommit(false);
|
|
|
}
|
|
|
}
|
|
@@ -631,9 +633,10 @@ class Db
|
|
|
|
|
|
public static function commit($host = 'master')
|
|
|
{
|
|
|
- if (!self::$iftransacte) {
|
|
|
+ if (!self::$iftransacte) {
|
|
|
$result = self::$link[$host]->commit();
|
|
|
- self::$link[$host]->autocommit(true);//开启自动提交
|
|
|
+ Log::record("autocommit end",Log::DEBUG);
|
|
|
+ self::$link[$host]->autocommit(true);//开启自动提交
|
|
|
self::$iftransacte = true;
|
|
|
if (!$result) throw_exception("Db Error: ".mysqli_error(self::$link[$host]));
|
|
|
}
|
|
@@ -641,9 +644,10 @@ class Db
|
|
|
|
|
|
public static function rollback($host = 'master')
|
|
|
{
|
|
|
- if (!self::$iftransacte){
|
|
|
+ if (!self::$iftransacte){
|
|
|
$result = self::$link[$host]->rollback();
|
|
|
- self::$link[$host]->autocommit(true);
|
|
|
+ Log::record("autocommit end",Log::DEBUG);
|
|
|
+ self::$link[$host]->autocommit(true);
|
|
|
self::$iftransacte = true;
|
|
|
if (!$result) throw_exception("Db Error: ".mysqli_error(self::$link[$host]));
|
|
|
}
|