I am trying to rewrite some code to eliminate the call_user_func_array
calls, and have the following code so far :
if($stmt = $this->_db->prepare($sql)) {
$bind_arguments = $this->params;
// remove first element (eg. 'ssiss')
$bind_arguments = array_shift($bind_arguments);
// execute query passing values
$res = $stmt->execute($bind_arguments);
}
Here is a var_export
of $this->params
:
array ( 0 => 's', 1 => 'admin', )
$res
always evaluates to null
when trying the above method. According to this comment, it appears that everything is correct, except my array has integer keys, and there is an additional ,
after the last element.
What do I need to do to format this array (removing the first element), to pass to the $stmt->execute
method as the variable containing the array elements (this is not a static array. elements in it are modified by other methods in the class to add or remove elements from it).