Added database prepare (#38 #214 #196)

This commit is contained in:
Tobias Reich 2014-08-29 19:12:35 +02:00
parent 4697698b03
commit 75e63a9e3a

View File

@ -219,6 +219,28 @@ if(!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
}
static function prepare($database, $query, $data) {
# Check dependencies
Module::dependencies(isset($database, $query, $data));
foreach ($data as $value) {
# Escape
$value = mysqli_real_escape_string($database, $value);
# Replace
$query = preg_replace('/\?/', $value, $query, 1);
}
# Add semicolon at the end
$query .= ';';
return $query;
}
}
?>