Re: call_user_func_array and bind_result

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Each *value* in the array must be a reference to an existing variable--they
cannot be null or direct values. I didn't try this with bind_param(), but I
create a function that takes reference arguments and got it to work with
call_user_func_array():

    function foo(&$x, &$y) { $x *= 2; $y *= 3; }
    $x = 2;
    $y = 1;
    $params = array(&$x, &$y);
    call_user_func_array('foo', $params);
    var_dump($p);

    array(2) {
      [0]=>
      &int(4)
      [1]=>
      &int(3)
    }

Try changing the loop where you package up the $params array. I'm not
exactly sure what that part in your code is supposed to do, but I believe
that you have a result set where each column name is the name of a property
in the AbstractModel subclass.

    foreach ($metadata as $object) {
        $field = $object->orgname;
        $params[] = &$this->$field;
    }

If that's not the case, you can create a $values array to receive the
actual values from the result set and have the $params array hold
references to those values.

    $values = array();
    foreach ($metadata as $object) {
        $field = $object->orgname;
        $params[$field] = null;
        $params[] = &$values[$field];
    }

Peace,
David

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux