Commit 78615580 authored by jianghaiming's avatar jianghaiming

update:set

parent 48662ee0
...@@ -129,7 +129,7 @@ abstract class MysqlBase ...@@ -129,7 +129,7 @@ abstract class MysqlBase
if (in_array($method, self::$writeFuncitonList)) { if (in_array($method, self::$writeFuncitonList)) {
// 写操作 // 写操作
$type = static::WRITE; $type = static::WRITE;
self::$dbConnect[$type] = self::getConnection($type); self::$dbConnect[static::CONFIG_INDEX.':'.$type] = self::getConnection($type);
if (strpos($method, 'Master') !== false) { if (strpos($method, 'Master') !== false) {
$method = substr_replace($method, '', -6); $method = substr_replace($method, '', -6);
} }
...@@ -137,7 +137,7 @@ abstract class MysqlBase ...@@ -137,7 +137,7 @@ abstract class MysqlBase
} elseif (in_array($method, self::$readFunctionList)) { } elseif (in_array($method, self::$readFunctionList)) {
// 读操作 // 读操作
$type = static::READ; $type = static::READ;
self::$dbConnect[$type] = self::getConnection($type); self::$dbConnect[static::CONFIG_INDEX.':'.$type] = self::getConnection($type);
array_unshift($arguments, static::TABLE_NAME); array_unshift($arguments, static::TABLE_NAME);
} elseif (strpos($method, 'query') !== false) { } elseif (strpos($method, 'query') !== false) {
// Medoo原生SQL操作 // Medoo原生SQL操作
...@@ -146,17 +146,17 @@ abstract class MysqlBase ...@@ -146,17 +146,17 @@ abstract class MysqlBase
$type = static::WRITE; $type = static::WRITE;
} }
$method = 'query'; $method = 'query';
self::$dbConnect[$type] = self::getConnection($type); self::$dbConnect[static::CONFIG_INDEX.':'.$type] = self::getConnection($type);
} else { } else {
throw new \Exception("use undefined Medoo function:" . $method . "-" . json_encode($arguments)); throw new \Exception("use undefined Medoo function:" . $method . "-" . json_encode($arguments));
} }
self::$dbCurrentConnect = self::$dbConnect[$type]; self::$dbCurrentConnect = self::$dbConnect[static::CONFIG_INDEX.':'.$type];
self::$sqlResut = call_user_func_array([self::$dbConnect[$type], $method], $arguments); self::$sqlResut = call_user_func_array([self::$dbConnect[static::CONFIG_INDEX.':'.$type], $method], $arguments);
if (!self::catchError($method, $arguments)) { if (!self::catchError($method, $arguments)) {
// 如果失败重试一次 // 如果失败重试一次
self::$dbCurrentConnect = self::$dbConnect[$type] = self::getConnection($type); self::$dbCurrentConnect = self::$dbConnect[static::CONFIG_INDEX.':'.$type] = self::getConnection($type);
self::$sqlResut = call_user_func_array([self::$dbConnect[$type], $method], $arguments); self::$sqlResut = call_user_func_array([self::$dbConnect[static::CONFIG_INDEX.':'.$type], $method], $arguments);
if (!self::catchError($method, $arguments)) { if (!self::catchError($method, $arguments)) {
return false; return false;
} }
...@@ -173,11 +173,11 @@ abstract class MysqlBase ...@@ -173,11 +173,11 @@ abstract class MysqlBase
*/ */
public static function getConnection($type, $flush = false) public static function getConnection($type, $flush = false)
{ {
if (!isset(self::$dbConnect[$type]) || $flush) { if (!isset(self::$dbConnect[static::CONFIG_INDEX.':'.$type]) || $flush) {
self::$dbConnect[$type] = new Medoo(self::getDbConf($type)); self::$dbConnect[static::CONFIG_INDEX.':'.$type] = new Medoo(self::getDbConf($type));
} }
return self::$dbConnect[$type]; return self::$dbConnect[static::CONFIG_INDEX.':'.$type];
} }
/** /**
...@@ -402,13 +402,13 @@ abstract class MysqlBase ...@@ -402,13 +402,13 @@ abstract class MysqlBase
public static function debug() public static function debug()
{ {
$type = static::WRITE; $type = static::WRITE;
self::$dbConnect[$type] = self::getConnection($type); self::$dbConnect[static::CONFIG_INDEX.':'.$type] = self::getConnection($type);
self::$dbConnect[$type]->debug(); self::$dbConnect[static::CONFIG_INDEX.':'.$type]->debug();
$type = static::READ; $type = static::READ;
self::$dbConnect[$type] = self::getConnection($type); self::$dbConnect[static::CONFIG_INDEX.':'.$type] = self::getConnection($type);
self::$dbConnect[$type]->debug(); self::$dbConnect[static::CONFIG_INDEX.':'.$type]->debug();
return [static::WRITE => self::$dbConnect[static::WRITE], static::READ => self::$dbConnect[static::READ]]; return [static::CONFIG_INDEX.':'.static::WRITE => self::$dbConnect[static::CONFIG_INDEX.':'.static::WRITE], static::CONFIG_INDEX.':'.static::READ => self::$dbConnect[static::CONFIG_INDEX.':'.static::READ]];
} }
/** /**
...@@ -420,11 +420,11 @@ abstract class MysqlBase ...@@ -420,11 +420,11 @@ abstract class MysqlBase
{ {
$ret = []; $ret = [];
$type = static::WRITE; $type = static::WRITE;
self::$dbConnect[$type] = self::getConnection($type); self::$dbConnect[static::CONFIG_INDEX.':'.$type] = self::getConnection($type);
$ret[$type] = self::$dbConnect[$type]->log(); $ret[$type] = self::$dbConnect[static::CONFIG_INDEX.':'.$type]->log();
$type = static::READ; $type = static::READ;
self::$dbConnect[$type] = self::getConnection($type); self::$dbConnect[static::CONFIG_INDEX.':'.$type] = self::getConnection($type);
$ret[$type] = self::$dbConnect[$type]->log(); $ret[$type] = self::$dbConnect[static::CONFIG_INDEX.':'.$type]->log();
return $ret; return $ret;
} }
...@@ -447,9 +447,9 @@ abstract class MysqlBase ...@@ -447,9 +447,9 @@ abstract class MysqlBase
public static function beginTransaction() public static function beginTransaction()
{ {
$type = static::WRITE; $type = static::WRITE;
self::$dbConnect[$type] = self::getConnection($type); self::$dbConnect[static::CONFIG_INDEX.':'.$type] = self::getConnection($type);
if(!self::$dbConnect[$type]->pdo->inTransaction()) { if(!self::$dbConnect[static::CONFIG_INDEX.':'.$type]->pdo->inTransaction()) {
return self::$dbConnect[$type]->pdo->beginTransaction(); return self::$dbConnect[static::CONFIG_INDEX.':'.$type]->pdo->beginTransaction();
} }
return false; return false;
} }
...@@ -462,9 +462,9 @@ abstract class MysqlBase ...@@ -462,9 +462,9 @@ abstract class MysqlBase
public static function commit() public static function commit()
{ {
$type = static::WRITE; $type = static::WRITE;
self::$dbConnect[$type] = self::getConnection($type); self::$dbConnect[static::CONFIG_INDEX.':'.$type] = self::getConnection($type);
if(self::$dbConnect[$type]->pdo->inTransaction()) { if(self::$dbConnect[static::CONFIG_INDEX.':'.$type]->pdo->inTransaction()) {
return self::$dbConnect[$type]->pdo->commit(); return self::$dbConnect[static::CONFIG_INDEX.':'.$type]->pdo->commit();
} }
return false; return false;
} }
...@@ -477,9 +477,9 @@ abstract class MysqlBase ...@@ -477,9 +477,9 @@ abstract class MysqlBase
public static function rollback() public static function rollback()
{ {
$type = static::WRITE; $type = static::WRITE;
self::$dbConnect[$type] = self::getConnection($type); self::$dbConnect[static::CONFIG_INDEX.':'.$type] = self::getConnection($type);
if(self::$dbConnect[$type]->pdo->inTransaction()) { if(self::$dbConnect[static::CONFIG_INDEX.':'.$type]->pdo->inTransaction()) {
return self::$dbConnect[$type]->pdo->rollback(); return self::$dbConnect[static::CONFIG_INDEX.':'.$type]->pdo->rollback();
} }
return false; return false;
} }
...@@ -492,7 +492,7 @@ abstract class MysqlBase ...@@ -492,7 +492,7 @@ abstract class MysqlBase
public static function action(callable $actions) public static function action(callable $actions)
{ {
$type = static::WRITE; $type = static::WRITE;
self::$dbConnect[$type] = self::getConnection($type); self::$dbConnect[static::CONFIG_INDEX.':'.$type] = self::getConnection($type);
return self::$dbConnect[$type]->action($actions); return self::$dbConnect[static::CONFIG_INDEX.':'.$type]->action($actions);
} }
} }
...@@ -198,7 +198,7 @@ abstract class MysqlClusterBase ...@@ -198,7 +198,7 @@ abstract class MysqlClusterBase
} }
} }
$end_time = microtime(true); $end_time = microtime(true);
MonUtil::dbMon(self::dbCurrentConnect['server'].'_'.self::dbCurrentConnect['port'] ?? 'unknow_mysql',$method,'mysql',$end_time-$start_time); MonUtil::dbMon(self::$dbCurrentConnect['server'].'_'.self::$dbCurrentConnect['port'] ?? 'unknow_mysql', $method, 'mysql', $end_time-$start_time);
return self::formatResult($method, $arguments); return self::formatResult($method, $arguments);
} }
......
...@@ -32,7 +32,7 @@ private static $installed = array ( ...@@ -32,7 +32,7 @@ private static $installed = array (
'aliases' => 'aliases' =>
array ( array (
), ),
'reference' => '7111c7a581d9d2216005db71482bf7ecdb031a49', 'reference' => '48662ee0ac551270f90d09cda3f0a1ab5d45c556',
'name' => 'yidian/yaf_demo', 'name' => 'yidian/yaf_demo',
), ),
'versions' => 'versions' =>
...@@ -45,7 +45,7 @@ private static $installed = array ( ...@@ -45,7 +45,7 @@ private static $installed = array (
array ( array (
0 => '9999999-dev', 0 => '9999999-dev',
), ),
'reference' => '8db8da38dc52e83358dfcb59aa7dcc259b4a80f6', 'reference' => '3a118172e1f4bb413ccbef92c037f4f3255b388a',
), ),
'api/php_utils' => 'api/php_utils' =>
array ( array (
...@@ -55,7 +55,7 @@ private static $installed = array ( ...@@ -55,7 +55,7 @@ private static $installed = array (
array ( array (
0 => '9999999-dev', 0 => '9999999-dev',
), ),
'reference' => '68a14dcde67b6d838b4933550a9356e5c78060b3', 'reference' => '16949fb782de0488cf192e3cd9d4e1268377294d',
), ),
'bacon/bacon-qr-code' => 'bacon/bacon-qr-code' =>
array ( array (
...@@ -335,7 +335,7 @@ private static $installed = array ( ...@@ -335,7 +335,7 @@ private static $installed = array (
'aliases' => 'aliases' =>
array ( array (
), ),
'reference' => '7111c7a581d9d2216005db71482bf7ecdb031a49', 'reference' => '48662ee0ac551270f90d09cda3f0a1ab5d45c556',
), ),
), ),
); );
......
...@@ -97,6 +97,7 @@ return array( ...@@ -97,6 +97,7 @@ return array(
'App\\Models\\goods\\mysql\\GoodsSnapshot' => $baseDir . '/application/models/goods/mysql/GoodsSnapshot.php', 'App\\Models\\goods\\mysql\\GoodsSnapshot' => $baseDir . '/application/models/goods/mysql/GoodsSnapshot.php',
'App\\Models\\goods\\mysql\\GoodsSpu' => $baseDir . '/application/models/goods/mysql/GoodsSpu.php', 'App\\Models\\goods\\mysql\\GoodsSpu' => $baseDir . '/application/models/goods/mysql/GoodsSpu.php',
'App\\Models\\goods\\mysql\\InventoryOperationRecord' => $baseDir . '/application/models/goods/mysql/InventoryOperationRecord.php', 'App\\Models\\goods\\mysql\\InventoryOperationRecord' => $baseDir . '/application/models/goods/mysql/InventoryOperationRecord.php',
'App\\Models\\goods\\mysql\\PaySuccessGoodsCallbackRecord' => $baseDir . '/application/models/goods/mysql/PaySuccessGoodsCallbackRecord.php',
'App\\Models\\goods\\mysql\\Shop' => $baseDir . '/application/models/goods/mysql/Shop.php', 'App\\Models\\goods\\mysql\\Shop' => $baseDir . '/application/models/goods/mysql/Shop.php',
'App\\Models\\goods\\mysql\\Tcc' => $baseDir . '/application/models/goods/mysql/Tcc.php', 'App\\Models\\goods\\mysql\\Tcc' => $baseDir . '/application/models/goods/mysql/Tcc.php',
'App\\Models\\marketing\\mysql\\Distributor' => $baseDir . '/application/models/marketing/mysql/Distributor.php', 'App\\Models\\marketing\\mysql\\Distributor' => $baseDir . '/application/models/marketing/mysql/Distributor.php',
......
...@@ -326,6 +326,7 @@ class ComposerStaticInit48fd9e88279ffd9162a19bdedd5d5a0a ...@@ -326,6 +326,7 @@ class ComposerStaticInit48fd9e88279ffd9162a19bdedd5d5a0a
'App\\Models\\goods\\mysql\\GoodsSnapshot' => __DIR__ . '/../..' . '/application/models/goods/mysql/GoodsSnapshot.php', 'App\\Models\\goods\\mysql\\GoodsSnapshot' => __DIR__ . '/../..' . '/application/models/goods/mysql/GoodsSnapshot.php',
'App\\Models\\goods\\mysql\\GoodsSpu' => __DIR__ . '/../..' . '/application/models/goods/mysql/GoodsSpu.php', 'App\\Models\\goods\\mysql\\GoodsSpu' => __DIR__ . '/../..' . '/application/models/goods/mysql/GoodsSpu.php',
'App\\Models\\goods\\mysql\\InventoryOperationRecord' => __DIR__ . '/../..' . '/application/models/goods/mysql/InventoryOperationRecord.php', 'App\\Models\\goods\\mysql\\InventoryOperationRecord' => __DIR__ . '/../..' . '/application/models/goods/mysql/InventoryOperationRecord.php',
'App\\Models\\goods\\mysql\\PaySuccessGoodsCallbackRecord' => __DIR__ . '/../..' . '/application/models/goods/mysql/PaySuccessGoodsCallbackRecord.php',
'App\\Models\\goods\\mysql\\Shop' => __DIR__ . '/../..' . '/application/models/goods/mysql/Shop.php', 'App\\Models\\goods\\mysql\\Shop' => __DIR__ . '/../..' . '/application/models/goods/mysql/Shop.php',
'App\\Models\\goods\\mysql\\Tcc' => __DIR__ . '/../..' . '/application/models/goods/mysql/Tcc.php', 'App\\Models\\goods\\mysql\\Tcc' => __DIR__ . '/../..' . '/application/models/goods/mysql/Tcc.php',
'App\\Models\\marketing\\mysql\\Distributor' => __DIR__ . '/../..' . '/application/models/marketing/mysql/Distributor.php', 'App\\Models\\marketing\\mysql\\Distributor' => __DIR__ . '/../..' . '/application/models/marketing/mysql/Distributor.php',
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://git.yidian-inc.com:8021/bp/php_services.git", "url": "https://git.yidian-inc.com:8021/bp/php_services.git",
"reference": "8db8da38dc52e83358dfcb59aa7dcc259b4a80f6" "reference": "3a118172e1f4bb413ccbef92c037f4f3255b388a"
}, },
"require": { "require": {
"api/php_utils": "dev-master", "api/php_utils": "dev-master",
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
"perftools/php-profiler": "^0.18.0", "perftools/php-profiler": "^0.18.0",
"php": "7.2.*" "php": "7.2.*"
}, },
"time": "2021-06-25T11:08:53+00:00", "time": "2021-06-25T11:16:31+00:00",
"default-branch": true, "default-branch": true,
"type": "library", "type": "library",
"installation-source": "source", "installation-source": "source",
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://git.yidian-inc.com:8021/bp/php_utils.git", "url": "https://git.yidian-inc.com:8021/bp/php_utils.git",
"reference": "68a14dcde67b6d838b4933550a9356e5c78060b3" "reference": "16949fb782de0488cf192e3cd9d4e1268377294d"
}, },
"require": { "require": {
"elasticsearch/elasticsearch": "~7.0", "elasticsearch/elasticsearch": "~7.0",
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
"mongodb/mongodb": "1.4.3", "mongodb/mongodb": "1.4.3",
"php": "7.2.*" "php": "7.2.*"
}, },
"time": "2021-06-25T07:16:28+00:00", "time": "2021-06-26T06:31:48+00:00",
"default-branch": true, "default-branch": true,
"type": "library", "type": "library",
"installation-source": "source", "installation-source": "source",
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
'aliases' => 'aliases' =>
array ( array (
), ),
'reference' => '7111c7a581d9d2216005db71482bf7ecdb031a49', 'reference' => '48662ee0ac551270f90d09cda3f0a1ab5d45c556',
'name' => 'yidian/yaf_demo', 'name' => 'yidian/yaf_demo',
), ),
'versions' => 'versions' =>
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
array ( array (
0 => '9999999-dev', 0 => '9999999-dev',
), ),
'reference' => '8db8da38dc52e83358dfcb59aa7dcc259b4a80f6', 'reference' => '3a118172e1f4bb413ccbef92c037f4f3255b388a',
), ),
'api/php_utils' => 'api/php_utils' =>
array ( array (
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
array ( array (
0 => '9999999-dev', 0 => '9999999-dev',
), ),
'reference' => '68a14dcde67b6d838b4933550a9356e5c78060b3', 'reference' => '16949fb782de0488cf192e3cd9d4e1268377294d',
), ),
'bacon/bacon-qr-code' => 'bacon/bacon-qr-code' =>
array ( array (
...@@ -309,7 +309,7 @@ ...@@ -309,7 +309,7 @@
'aliases' => 'aliases' =>
array ( array (
), ),
'reference' => '7111c7a581d9d2216005db71482bf7ecdb031a49', 'reference' => '48662ee0ac551270f90d09cda3f0a1ab5d45c556',
), ),
), ),
); );
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment