From b14416766d3c86e1d53e351b5a845b599bedcca5 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 22 Dec 2020 20:09:49 +0800 Subject: [PATCH] clearDB ok --- webapp/controller/GMController.class.php | 30 +++++++++++++----------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/webapp/controller/GMController.class.php b/webapp/controller/GMController.class.php index bcb61c6..c9cadcf 100644 --- a/webapp/controller/GMController.class.php +++ b/webapp/controller/GMController.class.php @@ -11,18 +11,6 @@ class GMController { } } - protected function getRedis($team_uuid) - { - $redis_conf = getRedisConfig(crc32($team_uuid)); - $r = new phpcommon\Redis(array( - 'host' => $redis_conf['host'], - 'port' => $redis_conf['port'], - 'passwd' => $redis_conf['passwd'] - - )); - return $r; - } - protected function getMysql($account_id) { $mysql_conf = getMysqlConfig(crc32($account_id)); @@ -38,7 +26,22 @@ class GMController { public function clearDB() { - + global $g_conf_mysql_cluster; + foreach ($g_conf_mysql_cluster as $mysql_conf) { + $conn = new phpcommon\Mysql(array( + 'host' => $mysql_conf['host'], + 'port' => $mysql_conf['port'], + 'user' => $mysql_conf['user'], + 'passwd' => $mysql_conf['passwd'], + 'dbname' => DBNAME_PREFIX . $mysql_conf['instance_id'] + )); + $tables = $conn->execQueryAsArray('show tables;'); + foreach ($tables as $table) { + $tblName = $table[0]; + $conn->execScript("DELETE FROM {$tblName};", + arary()); + } + } } public function getSysTime() @@ -67,5 +70,4 @@ class GMController { $r->set(GLOBAL_TIME_OFFSET_KEY, $time_offset); } - }