From 7776b35cab943f50d25f000a52eb5c345d92f5ba Mon Sep 17 00:00:00 2001 From: hide_d Date: Mon, 21 May 2018 00:23:50 +0900 Subject: [PATCH] =?UTF-8?q?kvstorage=20=EB=B2=84=EA=B7=B8=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/func.php | 2 +- hwe/func_time_event.php | 1 + hwe/sammo/Event/Action/ChangeCity.php | 4 ++-- src/sammo/KVStorage.php | 26 ++++++++++++++++------ vendor/sergeytsalkov/meekrodb/db.class.php | 2 ++ 5 files changed, 25 insertions(+), 10 deletions(-) diff --git a/hwe/func.php b/hwe/func.php index eb38bf22..6259afe0 100644 --- a/hwe/func.php +++ b/hwe/func.php @@ -1496,7 +1496,7 @@ function updateOnline() { } //접속중인 국가 - $gameStor->online = $onlinenume; + $gameStor->online = $onlinenum; $gameStor->onlinenation = $onnationstr; } diff --git a/hwe/func_time_event.php b/hwe/func_time_event.php index 17257de4..8c8f745d 100644 --- a/hwe/func_time_event.php +++ b/hwe/func_time_event.php @@ -46,6 +46,7 @@ function processSpring() { function processGoldIncome() { $db = DB::db(); $connect=$db->get(); + $gameStor = new KVStorage($db, 'game_env'); $admin = $gameStor->getValues(['year','month','gold_rate']); $adminLog = []; diff --git a/hwe/sammo/Event/Action/ChangeCity.php b/hwe/sammo/Event/Action/ChangeCity.php index de01f98d..13e09af8 100644 --- a/hwe/sammo/Event/Action/ChangeCity.php +++ b/hwe/sammo/Event/Action/ChangeCity.php @@ -140,10 +140,10 @@ class ChangeCity extends \sammo\Event\Action{ if($targetType == 'cities'){ if(is_numeric($this->targetArgs)){ - return DB::db()->queryFirstColumn('SELECT city FROM city WHERE city IN (%ls)', $this->targetArgs); + return DB::db()->queryFirstColumn('SELECT city FROM city WHERE city IN %ls', $this->targetArgs); } else{ - return DB::db()->queryFirstColumn('SELECT city FROM city WHERE name IN (%ls)', $this->targetArgs); + return DB::db()->queryFirstColumn('SELECT city FROM city WHERE name IN %ls', $this->targetArgs); } } diff --git a/src/sammo/KVStorage.php b/src/sammo/KVStorage.php index 43be78db..8cfc57bb 100644 --- a/src/sammo/KVStorage.php +++ b/src/sammo/KVStorage.php @@ -138,6 +138,9 @@ class KVStorage{ } public function getValuesAsArray(array $keys, bool $onlyCache=false): array{ + if(!$keys){ + return []; + } $dictResult = $this->getValues($keys, $onlyCache); $result = []; foreach($keys as $key){ @@ -147,6 +150,9 @@ class KVStorage{ } public function getValues(array $keys, bool $onlyCache=false): array{ + if(!$keys){ + return []; + } if ($this->cacheData === null) { return $this->getDBValues($keys); } @@ -224,7 +230,11 @@ class KVStorage{ } private function getDBValues(array $keys): array{ + if(!$keys){ + return []; + } $result = []; + $keys = array_map('strval', $keys); foreach($this->db->queryAllLists( 'SELECT `key`, `value` FROM %b WHERE `namespace`=%s AND `key` IN %ls', $this->tableName, @@ -243,6 +253,7 @@ class KVStorage{ } private function getDBValue($key){ + $key = (string)$key; $value = $this->db->queryFirstField( 'SELECT `value` FROM %b WHERE `namespace`=%s AND `key`=%s', $this->tableName, @@ -268,17 +279,18 @@ class KVStorage{ } private function deleteDBValue($key):self{ - $this->db->delete($this->tableName, [ - 'namespace'=>$this->storNamespace, - 'key'=>$key - ]); + $key = (string)$key; + $this->db->delete( + $this->tableName, + '`namespace`=%s AND `key`=%s', + $this->storNamespace, + $key + ); return $this; } private function resetDBNamespace():self{ - $this->db->delete($this->tableName, [ - 'namespace'=>$this->storNamespace - ]); + $this->db->delete($this->tableName, 'namespace=%s', $this->storNamespace); return $this; } } \ No newline at end of file diff --git a/vendor/sergeytsalkov/meekrodb/db.class.php b/vendor/sergeytsalkov/meekrodb/db.class.php index 75dfd90c..4dddfaac 100644 --- a/vendor/sergeytsalkov/meekrodb/db.class.php +++ b/vendor/sergeytsalkov/meekrodb/db.class.php @@ -645,6 +645,8 @@ class MeekroDB { 'code' => $db->errno )); } + + echo $sql."
\n"; if ($this->throw_exception_on_error) { $e = new MeekroDBException($db->error, $sql, $db->errno);