added ability to pass in a second array of parameter types

This commit is contained in:
Bryan Joshua Pedini 2021-01-29 16:15:00 +01:00
parent e9863f966a
commit 1e82ccf550
1 changed files with 4 additions and 2 deletions

View File

@ -20,10 +20,12 @@
}
}
public function bind_and_execute(?array $parameters = []) {
public function bind_and_execute(?array $parameters = [], ?array $paramtypes = []) {
if(isset($parameters)) {
foreach($parameters as $key => $val) {
if ($this->statement->bindValue($key, $val) === FALSE) {
$paramtype = PDO::PARAM_STR;
if(array_key_exists($key, $paramtypes)) $paramtype = $paramtypes[$key];
if ($this->statement->bindValue($key, $val, $paramtype) === FALSE) {
die("Binding parameters failed: ".$this->statement->errorInfo()[2]);
}
}