Update database.php
This commit is contained in:
parent
d035483d20
commit
bc362adbef
|
@ -41,13 +41,25 @@ if(!function_exists("get_dbc_object")) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!function_exists("get_db_stmt")) {
|
if(!function_exists("get_db_stmt")) {
|
||||||
function get_db_stmt($sql, $bind=array()) {
|
function get_db_stmt($sql, $bind=array(), $bind_pdo=false) {
|
||||||
$stmt = get_dbc_object()->prepare($sql);
|
if(!$bind_pdo) {
|
||||||
if(count($bind) > 0) {
|
if(count($bind) > 0) {
|
||||||
foreach($bind as $k=>$v) {
|
foreach($bind as $k=>$v) {
|
||||||
$stmt->bindParam(':' . $k, $v, PDO::PARAM_STR);
|
$sql = str_replace(":" . $k, "'" . addslashes($v) . "'", $sql);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
$stmt = get_dbc_object()->prepare($sql);
|
||||||
|
|
||||||
|
// bind parameter by PDO statement
|
||||||
|
if($bind_pdo) {
|
||||||
|
if(count($bind) > 0) {
|
||||||
|
foreach($bind as $k=>$v) {
|
||||||
|
$stmt->bindParam(':' . $k, $v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $stmt;
|
return $stmt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,13 +83,6 @@ if(!function_exists("exec_db_query")) {
|
||||||
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 {
|
} else {
|
||||||
$stmt = get_db_stmt($sql, $bind);
|
$stmt = get_db_stmt($sql, $bind);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user