I had trouble getting Prepared Statements in PHP with MySQLi, so here’s my solution. There are two issues that I had with this: passing a dynamic number of parameters to be bound, and that I wanted an associated array to be returned.
I used call_user_func_array to call a callback on my array of of parameters that I passed in. One issue with this approach is that the array needs to have all of the values be references, thus I used the makeValuesReferenced function that I found here, while fetchAssocArray is a user created function that I found here.
The function can be called like this: