Update database.php

This commit is contained in:
Namhyeon Go 2020-01-09 17:53:00 +09:00 committed by GitHub
parent 92de2eb40e
commit 29987d84ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -325,16 +325,16 @@ if(!check_function_exists("get_bind_to_sql_insert")) {
$num_duplicates = 0; $num_duplicates = 0;
// do process // do process
$_bind_T = array(); $_bind_K = array();
$_bind_F = array(); $_bind_V = array();
foreach($bind as $k=>$v) { foreach($bind as $k=>$v) {
if(in_array($k, $setduplicate)) { if(in_array($k, $setduplicate)) {
$_bind_T[$k] = $v; $_bind_K[$k] = $v;
} else { } else {
$_bind_F[$k] = $v; $_bind_V[$k] = $v;
} }
} }
$sql = get_bind_to_sql_select($tablename, $_bind_T, array( $sql = get_bind_to_sql_select($tablename, $_bind_K, array(
"getcnt" => true, "getcnt" => true,
"setwheres" => $setnotwhere "setwheres" => $setnotwhere
)); ));
@ -346,7 +346,7 @@ if(!check_function_exists("get_bind_to_sql_insert")) {
// make statements // make statements
if($num_duplicates > 0) { if($num_duplicates > 0) {
$sql = get_bind_to_sql_update($tablename, $bind, array( $sql = get_bind_to_sql_update($tablename, $bind, array(
"setkeys" => array_keys($_bind_T) "setkeys" => array_keys($_bind_K)
), $options); ), $options);
} else { } else {
$bind_keys = array_keys($bind); $bind_keys = array_keys($bind);
@ -678,16 +678,16 @@ if(!check_function_exists("get_bind_to_sql_update")) {
$sql = "update %s set %s where %s"; $sql = "update %s set %s where %s";
// bind `where` clause // bind `where` clause
$_bind_T = array(); $_bind_K = array();
$_bind_F = array(); $_bind_V = array();
// setkeys // setkeys
$setkeys = get_array(get_value_in_array("setkeys", $options, false)); $setkeys = get_array(get_value_in_array("setkeys", $options, false));
foreach($bind as $k=>$v) { foreach($bind as $k=>$v) {
if(in_array($k, $setkeys)) { if(in_array($k, $setkeys)) {
$_bind_T[$k] => $v; $_bind_K[$k] => $v;
} else { } else {
$_bind_F[$k] => $v; $_bind_V[$k] => $v;
} }
} }
@ -695,10 +695,10 @@ if(!check_function_exists("get_bind_to_sql_update")) {
$s1 = $tablename; $s1 = $tablename;
// s2: make 'update set' clause // s2: make 'update set' clause
$s2 = get_bind_to_sql_update_set($bind, array_keys($_bind_F), $options); $s2 = get_bind_to_sql_update_set($bind, array_keys($_bind_V), $options);
// s3: make 'where' clause // s3: make 'where' clause
$s3 = get_bind_to_sql_where($_bind_T, $options); $s3 = get_bind_to_sql_where($_bind_K, $options);
// make completed statements // make completed statements
$sql = get_db_binded_sql(sprintf($sql, $s1, $s2, $s3), $bind); $sql = get_db_binded_sql(sprintf($sql, $s1, $s2, $s3), $bind);