From 6a4c8e236a83584d6daadf806321478ca878f1f7 Mon Sep 17 00:00:00 2001 From: hide_d Date: Sat, 31 Mar 2018 17:18:35 +0900 Subject: [PATCH] =?UTF-8?q?multi=5Fquery=20warning=20=EB=82=98=EB=8A=94=20?= =?UTF-8?q?=EB=AC=B8=EC=A0=9C=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- f_install/j_setup_db.php | 9 ++++++++- twe/func_gamerule.php | 20 +++++++------------- twe/j_install.php | 19 +++++++++++++++++-- twe/j_install_db.php | 9 ++++++++- 4 files changed, 40 insertions(+), 17 deletions(-) diff --git a/f_install/j_setup_db.php b/f_install/j_setup_db.php index 7e47fc8a..a4550e9d 100644 --- a/f_install/j_setup_db.php +++ b/f_install/j_setup_db.php @@ -124,7 +124,14 @@ $rootDB->error_handler = 'dbSQLFail'; $mysqli_obj = $rootDB->get(); //로그인에 실패할 경우 자동으로 dbConnFail()이 실행됨. if($mysqli_obj->multi_query(file_get_contents(__dir__.'/sql/common_schema.sql'))){ - while (@$mysqli_obj->next_result()) {;} + while(true){ + if (!$mysqli_obj->more_results()) { + break; + } + if(!$mysqli_obj->next_result()){ + break; + } + } } $rootDB->insert('system', array( diff --git a/twe/func_gamerule.php b/twe/func_gamerule.php index 85880114..e9e230c7 100644 --- a/twe/func_gamerule.php +++ b/twe/func_gamerule.php @@ -207,26 +207,20 @@ function SetNationFront($nationNo) { $adj = []; $db = DB::db(); - $warNations = $db->queryFirstColumn( - 'SELECT you from diplomacy where me = %i and (state=0 or (state=1 and term<=3))' + $enemyCities = $db->queryFirstColumn( + 'SELECT city from city where nation IN + (SELECT you from diplomacy where me = %i and (state=0 or (state=1 and term<=3)))' , $nationNo ); - if($warNations) { - foreach($warNations as $warNation){ - $enemyCities = $db->queryFirstColumn('SELECT city from city where nation=%i', $warNation); - foreach($enemyCities as $city){ - foreach(CityConst::byID($city)->path as $adjCity){ - $adj[$adjCity] = 1; - } - } + if($enemyCities) { + foreach($enemyCities as $city){ + $adj = array_merge($adj, CityConst::byID($city)->path); } } else { //평시이면 공백지 //NOTE: if, else일 경우 NPC는 전쟁시에는 공백지로 출병하지 않는다는 뜻이 된다. foreach ($db->queryFirstColumn('SELECT city,path from city where nation=0') as $city) { - foreach(CityConst::byID($city)->path as $adjCity){ - $adj[$adjCity] = 1; - } + $adj = array_merge($adj, CityConst::byID($city)->path); } } diff --git a/twe/j_install.php b/twe/j_install.php index 3e4bc3eb..4056ad36 100644 --- a/twe/j_install.php +++ b/twe/j_install.php @@ -63,11 +63,26 @@ $scenarioObj = new Scenario($scenario); $startyear = $scenarioObj->getYear(); if($mysqli_obj->multi_query(file_get_contents(__dir__.'/sql/reset.sql'))){ - while (@$mysqli_obj->next_result()) {;} + while(true){ + if (!$mysqli_obj->more_results()) { + break; + } + if(!$mysqli_obj->next_result()){ + break; + } + } + } if($mysqli_obj->multi_query(file_get_contents(__dir__.'/sql/schema.sql'))){ - while (@$mysqli_obj->next_result()) {;} + while(true){ + if (!$mysqli_obj->more_results()) { + break; + } + if(!$mysqli_obj->next_result()){ + break; + } + } } diff --git a/twe/j_install_db.php b/twe/j_install_db.php index ec78e1cf..bfeda051 100644 --- a/twe/j_install_db.php +++ b/twe/j_install_db.php @@ -30,7 +30,14 @@ if($fullReset && class_exists('\\sammo\\DB')){ $mysqli_obj = DB::db()->get(); if($mysqli_obj->multi_query(file_get_contents(__dir__.'/sql/reset.sql'))){ - while (@$mysqli_obj->next_result()) {;} + while(true){ + if (!$mysqli_obj->more_results()) { + break; + } + if(!$mysqli_obj->next_result()){ + break; + } + } } }