So I had built a dynamic MySQLi query class to handle all of my querys, and it was reuseable. Anyways. How I do it, is using this:
vref() being a function that passes all that variables through references.
So I used the above to do something like this:
And I kept getting the error, "incorrect number of binds to variables." So I checked, double checked, triple, checked... And so forth. Until this morning when I wrote out the MySQLi by hand, and manually entered each value into the $stmt->bind_param(). Then I got the error, "Could not pass parameter 3 as reference." Ok, so I need to actually pass a variable to the bind param, ok I'll change that.
But whats confusing is this: I pass all the values through the array. Then submit that array to the call_user_func_ array() but that array apparently needs to have variables in it for reference passing as well? I don't get this. Is this because of the 5.3 reference passing thing anyways? ( I don't know what changed in 5.3 to make this a nessecary change in the first place )
Edit: To give more of a quickie understanding of my lack of understanding.. .
Code:
call_user_func_array( array( $stmt, 'bind_param' ), vref($arr) );
So I used the above to do something like this:
Code:
$arr = array( $_FORM['data1'], $_FORM['data2'], '0', '0', ( $_FORM['data3'] ) ? $_FORM['data3'] : '0' ); call_user_func_array( array( $stmt, 'bind_param' ), vref($arr) );
But whats confusing is this: I pass all the values through the array. Then submit that array to the call_user_func_ array() but that array apparently needs to have variables in it for reference passing as well? I don't get this. Is this because of the 5.3 reference passing thing anyways? ( I don't know what changed in 5.3 to make this a nessecary change in the first place )
Edit: To give more of a quickie understanding of my lack of understanding.. .
Code:
$db = new mysqli(CONFIG_DBHOST, CONFIG_DBUSER, CONFIG_DBPASS, CONFIG_DBNAME); $stmt = $db->prepare($query); $stmt->bind_param('ss',$_FORM['data1'],$_FORM['data2']); // Works $stmt->bind_param('ss','0','0'); // Does not work
Comment