This question already has an answer here:
I have a function that can take any number of parameters like below:
public function executePreparedStatement($query, $paramString = ''){
$stmt = $this->db->prepare($query);
if (func_num_args() > 2){
$parameters = func_get_args();
array_shift($parameters); // Get rid of the query
$parameters = array('s', 'email@email.com'); //Hard code for test
call_user_func_array(array($stmt, "bind_param"), $parameters);
// $stmt->bind_param($parameters[0], $parameters[1]); //Hard code for test
}
$stmt->execute();
$this->result = $stmt->get_result();
$stmt->close();
}
The problem is when I run the code as is, The stmt object displays:
No data supplied for parameters in prepared statement
But when I comment out the call_user_func_array
call and uncomment the subsequent line, the query works.
</div>