I am writing a wrapper class for MySQLi. In there, I am writing a function to accept a query and variable number of parameters where I can invoke mysqli_stmt::bind_param
. Here is the code:
<?php
class DbHelper {
....
public function Execute($query, $params){
$this->open(); # Opens a connection to the database using MySQLi API
$stmt = $this->mysqli->prepare($query);
try{
$result = call_user_func_array(array($stmt, 'bind_param'), $params);
}
catch(Exception $ex){
# Handle Exception
}
}
....
}
?>
Here's how I am calling the function:
<?php
$db = new DbHelper();
$params = array('i', $stateID);
$result = $db->Execute('SELECT * FROM mst_cities WHERE State_ID = ?', $params);
?>
When I run the code, I get an warning as this:
Warning: Parameter 2 to mysqli_stmt::bind_param() expected to be a reference, value given in......
What should I do?