I'm trying to write a variable number of arguments to a table. I was looking in the php documentation of bind_param and it mentioned using a ReflectionClass and invokeArgs to do it. I've been trying and I can't get it to work.
Say this is my array. The first argument is the types string:
$myarr =>
(
[0] = String(20) "sssssi"
[1] = String(6) "'test'"
[2] = String(5) "'ttt'"
[3] = String(8) "'tester'"
[4] = String(12) "'2015-01-01'"
[5] = String(6) "'test'"
[6] = Integer(1) 0
)
And here is the code:
Please help me understand what I'm doing wrong. Thanks!Code:$res = $mysqli->prepare($qry); $ref = new ReflectionClass('mysqli_stmt'); $method = $ref->getMethod("bind_param"); $method->invokeArgs($res,$myarr); $res->execute();


Reply With Quote
Bookmarks