Update database.php

This commit is contained in:
Namhyeon Go 2019-09-25 16:48:08 +09:00 committed by GitHub
parent 96874a7cae
commit 9cb1bd6638
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -299,7 +299,20 @@ if(!check_function_exists("get_page_range")) {
}
if(!check_function_exists("get_bind_to_sql_insert")) {
function get_bind_to_sql_insert($tablename, $bind) {
function get_bind_to_sql_insert($tablename, $bind, $options=array()) {
// check ignore
if(!array_key_empty("ignore", $options)) {
$row = exec_db_fetch(get_bind_to_sql_select($tablename, false, array(
"getcnt" => true,
"setwheres" => $options['ignore']
)), false);
$cnt = $row['cnt'];
if($cnt > 0) {
return "select " . $cnt;
}
}
// make SQL statement
$bind_keys = array_keys($bind);
$sql = "insert into %s (%s) values (:%s)";
@ -308,7 +321,7 @@ if(!check_function_exists("get_bind_to_sql_insert")) {
$s3 = implode(", :", $bind_keys);
$sql = sprintf($sql, $s1, $s2, $s3);
return $sql;
}
}