just wanted to share here, how we can use prepare statement with the combination of ... operator effectively .
<?php
class Database{
private function getTypeofValues($string, $value){
if(is_float($value)){
$string .= "d";
}elseif(is_integer($value)){
$string .= "i";
}elseif(is_string($value)){
$string .= "s";
}else{
$string .= "b";
}
return $string;
}
public function makeQuery($query, array $values){
$stmt = $this->connection->prepare($query);
$type = array_reduce($values, array($this, "getTypeOfValues"));
$stmt->bind_param($type, ...$values);
$stmt->execute();
$result = $stmt->get_result();
return $result;
}
}
?>