Skip to content
Advertisement

Bind Param with array of parameters

I have a function that does this:

JavaScript

Which sends off to my database class, which does this:

JavaScript

The problem is this doesn’t work.

What I was hoping to do, was to take the $params list and have it list them after the $type, so that the query would resemble:

JavaScript

But obviously I’m going about it the wrong way.

is there a way to make the array…transform as it were, into a list to be printed out at the bind_param query stage?

Advertisement

Answer

call_user_func_array “Call a callback with an array of parameters”

JavaScript

should do the job

UPDATE: you have also to change your params array:

JavaScript

as mysqli_stmt::bind_param expects the second and the following parameters by reference.


EDIT: Your query seems to be wrong. Maybe you have less fields than you have variables there. Do:

JavaScript

where you replace the name of the fields by the correct names

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement