MySQLi bind_param arguments
Posted: Fri Jan 19, 2007 5:44 pm
feyd | Please use
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!
Zoomerz (aka Randy)
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi All;
I'm trying to find a good way to dynamically fill the "variable" arguments to a mysqli_bind_param() method. I have incoming $_GET vars, which if !empty, need to be passed to the bind_param. In code:Code: Select all
$myFirstVar = !empty($_GET['var']) ? $_GET['var'] : false;
$mySecondVar = !empty($_GET['var']) ? $_GET['var'] : false; (etc)
$aryFields[] = $myFirstVar ? "firstField = ?";
$aryFields[] = $mySecondVar ? "secondField = ?"; (etc)
/*I'm also using an array to hold the correspondint "?" types, which are then imploded into the first bind_param('string of types'), which results in some string like 'sissi' or whatever*/
//the statement is dynamically built if the ary members exist
$sql = "UPDATE myTable SET firstField = ?, secondField = ? WHERE some condition exists";
**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.Any ideas? And thanks!
Zoomerz (aka Randy)
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]