Update database.php

This commit is contained in:
Namhyeon Go 2018-02-13 16:37:27 +09:00 committed by GitHub
parent 68877fbb97
commit ac6cba6e50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,16 +13,7 @@ $conn->query("SET NAMES 'utf8'");
if(!function_exists("sql_query")) {
function sql_query($sql, $bind=array()) {
global $conn;
$stmt = $conn->prepare($sql);
if(count($bind) > 0) {
foreach($bind as $k=>$v) {
$stmt->bindParam(':' . $k, $v);
}
}
return $stmt;
return get_db_stmt($sql, $bind);
}
}
@ -81,5 +72,16 @@ function exec_db_query($sql, $bind=array(), $options=array()) {
return $flag;
}
function exec_db_fetch_all($sql, $bind=array()) {
$rows = array();
$stmt = get_db_stmt($sql, $bind);
if($stmt->execute() && $stmt->rowCount() > 0) {
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
}
return $rows;
}
// set global db connection variable
$dbc = get_db_connect();