I use the following code to retrieve data from sql in php
if ($q=$db->prepare("call p_test(?)")){
$q->bind_param('s',$token);
$q->execute();
$q->bind_result($r1, $r2, $r3);
if ($q->fetch()){
echo $r1.
}
}
above code works fine when it’s not calling a procedure. but when I use to call a procedure, I face with a strange problem with the result set.
when the procedure returns only one column $r1 will be filled out. but when I have more than one columns in result, fetch is done but no result’s given.
in both tests the number of result and bind_result columns are same.
I can’t understand the reason for such behavior. am I going wrong with the way I try to get the expected result from a procedure?
It’s possible your procedure is returning more than one result set. You might need to use something like
next_result(at least that’s what it is in mysqli).