Update database.php

This commit is contained in:
Namhyeon Go 2018-04-29 01:32:24 +09:00 committed by GitHub
parent bb11f2d9a3
commit 9b7b22be25
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -75,7 +75,8 @@ if(!function_exists("get_db_stmt")) {
$stmt = get_dbc_object()->prepare($sql);
if($show_sql) {
var_dump($sql);
set_error($sql, "DATABASE-SQL");
show_errors(false);
}
// bind parameter by PDO statement
@ -137,11 +138,17 @@ if(!function_exists("exec_db_query")) {
$stmt_executed = $is_insert_with_bind ? $stmt->execute($bind) : $stmt->execute();
if($show_debug) {
var_dump($stmt->debugDumpParams());
$stmt->debugDumpParams();
}
if($display_error) {
var_dump($stmt->errorInfo());
$error_info = $stmt->errorInfo();
if(count($error_info) > 0) {
foreach($error_info as $err) {
set_error($err, "DATABASE-ERROR");
}
}
show_errors(false);
}
if($is_check_count == true) {
@ -156,6 +163,10 @@ if(!function_exists("exec_db_query")) {
$dbc->commit();
}
if($flag === false) {
set_error(md5($sql), "DATABASE-QUERY-FAILURE");
}
return $flag;
}
}
@ -286,8 +297,15 @@ if(!function_exists("json_decode_to_assoc")) {
function json_decode_to_assoc($data) {
$result = array();
$obj = @json_decode($data, true);
$result = (@json_last_error() === 0) ? $obj : $result;
$func_rules = array(
"json_decode" => "Dose not exists json_decode function",
"json_last_error" => "Dose not exists json_last_error function",
);
if(check_function_exists($func_rules)) {
$obj = @json_decode($data, true);
$result = (@json_last_error() === 0) ? $obj : $result;
}
return $result;
}