[UPHPU] PHP MySQLi bind_param arguments

Jacob Wright jacwright at gmail.com
Sat Jan 20 08:20:32 MST 2007

> **this is the part that's thowing me***
> /*I need to now call $db->bind_param('ississ', $arg1, $arg2) dynamically
> for
> only those fields that are to be updated. I'm looking for a good way to
> create $arg1, arg2 as necessary. I can create a single string easily
> enough
> from a dynamic array, but then there's a mismatch of types->arguments to
> replace.
> What I really need (I think) is an array_func ??? that will seperate the
> array members into comma delimited string variable arguments (not a single
> string argument)*/
> Any ideas? And thanks!

Are you looking for something like this?

// add your string first
$params = array('ississ');

// add parameters as needed
if ($arg1) $params[] = $arg1;
if ($arg2) $params[] = $arg2;

// make the call with the parameters (for object methds you pass in an array
of [object, method] to make the call)
*call_user_func_array* (array($db, "bind_param"), $params);

Jacob Wright
Within Code LLC

More information about the UPHPU mailing list