www.webdeveloper.com
Results 1 to 1 of 1

Thread: bind_param with dynamic # of variables

  1. #1
    Join Date
    Mar 2010
    Posts
    11

    bind_param with dynamic # of variables

    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:
    Code:
    $res    = $mysqli->prepare($qry);
    $ref    = new ReflectionClass('mysqli_stmt');
    $method = $ref->getMethod("bind_param");
    $method->invokeArgs($res,$myarr);
    $res->execute();
    Please help me understand what I'm doing wrong. Thanks!
    Last edited by raphael75; 04-06-2012 at 06:49 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles