newDB 함수 사용시 static 변수로 DB Object를 보관하도록 설정. 모든 update 명령은 global lock 하에서 통제되므로 이 방식을 사용할 수 있음.
This commit is contained in:
@@ -17,7 +17,13 @@ function newRootDB(){
|
|||||||
$port = _port_;
|
$port = _port_;
|
||||||
$encoding = 'utf8';
|
$encoding = 'utf8';
|
||||||
|
|
||||||
return new MeekroDB($host,$user,$password,$dbName,$port,$encoding);
|
static $uDB = NULL;
|
||||||
|
|
||||||
|
if($uDB === NULL){
|
||||||
|
$uDB = new MeekroDB($host,$user,$password,$dbName,$port,$encoding);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $uDB;
|
||||||
}
|
}
|
||||||
|
|
||||||
function newMailObj(){
|
function newMailObj(){
|
||||||
|
|||||||
@@ -14,5 +14,11 @@ function newDB(){
|
|||||||
$port = _port_;
|
$port = _port_;
|
||||||
$encoding = 'utf8';
|
$encoding = 'utf8';
|
||||||
|
|
||||||
return new MeekroDB($host,$user,$password,$dbName,$port,$encoding);
|
static $uDB = NULL;
|
||||||
|
|
||||||
|
if($uDB === NULL){
|
||||||
|
$uDB = new MeekroDB($host,$user,$password,$dbName,$port,$encoding);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $uDB;
|
||||||
}
|
}
|
||||||
+22
-4
@@ -66,11 +66,11 @@ function getRawMessage($mailbox, $limit=30, $fromTime=NULL){
|
|||||||
|
|
||||||
$db = newDB();
|
$db = newDB();
|
||||||
//TODO: table 네임의 prefix를 처리할 수 있도록 개선
|
//TODO: table 네임의 prefix를 처리할 수 있도록 개선
|
||||||
$result = $db->query($sql, array(
|
$result = $db->query($sql, [
|
||||||
'mailbox' => $mailbox,
|
'mailbox' => $mailbox,
|
||||||
'limit' => $limit,
|
'limit' => $limit,
|
||||||
'time' => $fromTime
|
'time' => $fromTime
|
||||||
));
|
]);
|
||||||
|
|
||||||
|
|
||||||
return array_map(function ($row){
|
return array_map(function ($row){
|
||||||
@@ -78,7 +78,25 @@ function getRawMessage($mailbox, $limit=30, $fromTime=NULL){
|
|||||||
}, $result);
|
}, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getMessage(){
|
function getMessage($msgType, $limit=30, $fromTime=NULL){
|
||||||
|
$genID = util::array_get($_SESSION['p_id'], NULL);
|
||||||
|
if($genID === NULL){
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
if($msgType === 'public'){
|
||||||
|
return getRawMessage(9999, $limit, $fromTime);
|
||||||
|
}
|
||||||
|
else if($msgType === 'private'){
|
||||||
|
return getRawMessage($genID, $limit, $fromTime);
|
||||||
|
}
|
||||||
|
else if($msgType === 'national'){
|
||||||
|
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,7 +105,7 @@ function genList($connect) {
|
|||||||
$query = "select no,nation,level,msgindex,userlevel from general where user_id='{$_SESSION['p_id']}'";
|
$query = "select no,nation,level,msgindex,userlevel from general where user_id='{$_SESSION['p_id']}'";
|
||||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||||
$me = MYDB_fetch_array($result);
|
$me = MYDB_fetch_array($result);
|
||||||
$you = array();
|
$you = [];
|
||||||
|
|
||||||
$query = "select msg{$me['msgindex']}_who as reply,msg{$me['msgindex']}_type as type from general where user_id='{$_SESSION['p_id']}'";
|
$query = "select msg{$me['msgindex']}_who as reply,msg{$me['msgindex']}_type as type from general where user_id='{$_SESSION['p_id']}'";
|
||||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||||
|
|||||||
Reference in New Issue
Block a user