Update database.php
This commit is contained in:
parent
b95337e188
commit
d035483d20
|
@ -45,7 +45,7 @@ if(!function_exists("get_db_stmt")) {
|
||||||
$stmt = get_dbc_object()->prepare($sql);
|
$stmt = get_dbc_object()->prepare($sql);
|
||||||
if(count($bind) > 0) {
|
if(count($bind) > 0) {
|
||||||
foreach($bind as $k=>$v) {
|
foreach($bind as $k=>$v) {
|
||||||
$stmt->bindParam(':' . $k, $v);
|
$stmt->bindParam(':' . $k, $v, PDO::PARAM_STR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $stmt;
|
return $stmt;
|
||||||
|
@ -66,13 +66,20 @@ if(!function_exists("exec_db_query")) {
|
||||||
$is_insert_with_bind = false;
|
$is_insert_with_bind = false;
|
||||||
|
|
||||||
$sql_terms = explode(" ", $sql);
|
$sql_terms = explode(" ", $sql);
|
||||||
if($sql_terms[0] != "insert") {
|
if($sql_terms[0] == "insert") {
|
||||||
$stmt = get_db_stmt($sql, $bind);
|
|
||||||
} else {
|
|
||||||
$stmt = get_db_stmt($sql);
|
$stmt = get_db_stmt($sql);
|
||||||
if(count($bind) > 0) {
|
if(count($bind) > 0) {
|
||||||
$is_insert_with_bind = true;
|
$is_insert_with_bind = true;
|
||||||
}
|
}
|
||||||
|
} else if($sql_terms[0] == "update") {
|
||||||
|
if(count($bind) > 0) {
|
||||||
|
foreach($bind as $k=>$v) {
|
||||||
|
$sql = str_replace(":" . $k, "'" . addslashes($v) . "'", $sql);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$stmt = get_db_stmt($sql);
|
||||||
|
} else{
|
||||||
|
$stmt = get_db_stmt($sql, $bind);
|
||||||
}
|
}
|
||||||
|
|
||||||
$validOptions = array();
|
$validOptions = array();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user