Commit 78615580 authored by jianghaiming's avatar jianghaiming

update:set

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