Skip to content

Commit

Permalink
Update database.php
Browse files Browse the repository at this point in the history
  • Loading branch information
gnh1201 authored Jan 1, 2020
1 parent 66eebcf commit 140a20c
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions system/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* @file database.php
* @created_on 2018-04-13
* @updated_on 2020-01-01
* @updated_on 2020-01-02
* @author Go Namhyeon <[email protected]>
* @brief Database module
*/
Expand Down Expand Up @@ -344,7 +344,7 @@ function get_bind_to_sql_insert($tablename, $bind, $options=array()) {
if(!check_function_exists("get_bind_to_sql_where")) {
// warning: variable k is not protected. do not use variable k and external variable without filter
function get_bind_to_sql_where($bind, $options=array(), $_options=array()) {
$s3 = "";
$s3 = "1";
$sp = "";

$excludes = get_value_in_array("excludes", $options, array());
Expand Down Expand Up @@ -664,7 +664,7 @@ function get_bind_to_sql_update($tablename, $bind, $options=array(), $_options=a

if(!check_function_exists("get_bind_to_sql_delete")) {
function get_bind_to_sql_delete($tablename, $bind, $options=array()) {
$sql = sprintf("delete from %s where %s", $tablename, get_db_binded_sql(get_bind_to_sql_where($bind, $options), $bind));
$sql = sprintf("delete from `%s` where %s", $tablename, get_db_binded_sql(get_bind_to_sql_where($bind, $options), $bind));
return $sql;
}
}
Expand Down Expand Up @@ -737,11 +737,11 @@ function get_bind_to_sql_create($schemes, $options=array()) {
if(is_array($v)) {
$_argc = count($v);
if($_argc == 1) {
$_schemes[] = sprintf("%s %s", $k, $v[0]);
$_schemes[] = sprintf("`%s` %s", $k, $v[0]);
} elseif($_argc == 2) {
$_schemes[] = sprintf("%s %s(%s)", $k, $v[0], $v[1]);
$_schemes[] = sprintf("`%s` %s(%s)", $k, $v[0], $v[1]);
} elseif($_argc == 3) {
$_schemes[] = sprintf("%s %s(%s) %s", $k, $v[0], $v[1], ($v[2] === true ? "not null" : ""));
$_schemes[] = sprintf("`%s` %s(%s) %s", $k, $v[0], $v[1], ($v[2] === true ? "not null" : ""));
}
}
}
Expand Down Expand Up @@ -787,6 +787,7 @@ function exec_db_table_create($schemes, $tablename, $options=array()) {
$sql = get_bind_to_sql_create($schemes, array(
"tablename" => $_tablename
));

if(!exec_db_query($sql)) {
return false;
} else {
Expand Down Expand Up @@ -851,7 +852,6 @@ function exec_db_temp_create($schemes, $options=array()) {
function exec_db_temp_start($sql, $bind=array(), $options=array()) {
$_tablename = make_random_id();
$_sql = sprintf("create temporary table if not exists `%s` %s", $_tablename, get_db_binded_sql($sql, $bind));
write_common_log($_sql);
return (exec_db_query($_sql) ? $_tablename : false);
}
}
Expand Down

0 comments on commit 140a20c

Please sign in to comment.