conditional parameter (nullable)

This commit is contained in:
Bryan Joshua Pedini 2021-01-28 22:10:20 +01:00
parent ba4f3a6158
commit e9863f966a
1 changed files with 6 additions and 4 deletions

View File

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