Last active
December 31, 2018 05:31
-
-
Save damulhan/1fb4e37b1d17382be09aa1e90907d475 to your computer and use it in GitHub Desktop.
Kimsq RB (1.x) php 7.0 patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Kimsq RB (1.x) php 7.0 patch | |
// 문의: https://github.com/damulhan | |
// | |
// File: /_core/function/db.mysql.func.php | |
// Kimq RB -- database 관련 루틴이며, php 7.0에서 mysql_* 관련 함수들이 동작하지 | |
// 않으며 mysqli_* 로 변경해야 합니다. | |
// 이와 같이 변경을 함으로서 기본적인 동작이 될 수 있도록 하였습니다. | |
function isConnectDb($db) | |
{ | |
$conn = mysqli_connect($db['host'], $db['user'], $db['pass'], $db['name'], $db['port']); | |
if (mysqli_connect_errno()) { | |
printf("Connect failed: %s\n", mysqli_connect_error()); | |
exit(); | |
} else { | |
return $conn; | |
} | |
} | |
function db_query($sql,$con) | |
{ | |
mysqli_query($con,'set names utf8'); | |
mysqli_query($con,'set sql_mode=\'\''); | |
return mysqli_query($con,$sql); | |
} | |
function db_fetch_array($que) | |
{ | |
return @mysqli_fetch_array($que); | |
} | |
function db_fetch_assoc($que) | |
{ | |
return mysqli_fetch_assoc($que); | |
} | |
function db_num_rows($que) | |
{ | |
return mysqli_num_rows($que); | |
} | |
function db_info() | |
{ | |
global $DB_CONNECT; | |
return mysqli_get_server_info($DB_CONNECT); | |
} | |
function db_error() | |
{ | |
global $DB_CONNECT; | |
return mysqli_error($DB_CONNECT); | |
} | |
function db_close($conn) | |
{ | |
return mysqli_close($conn); | |
} | |
function db_insert_id($conn) | |
{ | |
return mysqli_insert_id($conn); | |
} | |
//DB-UID데이터 | |
function getUidData($table,$uid) | |
{ | |
return getDbData($table,'uid='.(int)$uid,'*'); | |
} | |
//DB데이터 1ROW | |
function getDbData($table,$where,$data) | |
{ | |
return db_fetch_array(getDbSelect($table,getSqlFilter($where),$data)); | |
} | |
//DB데이터 ARRAY | |
function getDbArray($table,$where,$data,$sort,$orderby,$recnum,$p) | |
{ | |
global $DB_CONNECT; | |
$rcd = db_query('select '.$data.' from '.$table.($where?' where '.getSqlFilter($where):''). | |
(($sort || $orderby) ? (' order by '.$sort.' '.$orderby) : ""). | |
($recnum?' limit '.(($p-1)*$recnum).', '.$recnum:''),$DB_CONNECT); | |
return $rcd; | |
} | |
//DB데이터 NUM | |
function getDbRows($table,$where) | |
{ | |
global $DB_CONNECT; | |
$rows = db_fetch_array(db_query('select count(*) from '.$table.($where?' where '.getSqlFilter($where):''),$DB_CONNECT)); | |
return $rows[0] ? $rows[0] : 0; | |
} | |
//DB데이터 MAX | |
function getDbCnt($table,$type,$where) | |
{ | |
global $DB_CONNECT; | |
$cnts = db_fetch_array(db_query('select '.$type.' from '.$table.($where?' where '.getSqlFilter($where):''),$DB_CONNECT)); | |
return $cnts[0] ? $cnts[0] : 0; | |
} | |
//DB셀렉트 | |
function getDbSelect($table,$where,$data) | |
{ | |
global $DB_CONNECT; | |
$r = db_query('select '.$data.' from '.$table.($where?' where '.getSqlFilter($where):''),$DB_CONNECT); | |
return $r; | |
} | |
//DB삽입 | |
function getDbInsert($table,$key,$val) | |
{ | |
global $DB_CONNECT; | |
db_query("insert into ".$table." (".$key.")values(".$val.")",$DB_CONNECT); | |
} | |
//DB업데이트 | |
function getDbUpdate($table,$set,$where) | |
{ | |
global $DB_CONNECT; | |
db_query("update ".$table." set ".$set.($where?' where '.getSqlFilter($where):''),$DB_CONNECT); | |
} | |
//DB삭제 | |
function getDbDelete($table,$where) | |
{ | |
global $DB_CONNECT; | |
db_query("delete from ".$table.($where?' where '.getSqlFilter($where):''),$DB_CONNECT); | |
} | |
//SQL필터링 - 다음 패치에 적용예정 | |
function getSqlFilter($sql) | |
{ | |
return $sql; | |
//return mysql_real_escape_string($sql); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment