Forum Moderators: coopster
My question is what is the best way to package (especially the multiple row results) and send these results back through the function to the SOAP client? Do I need to take apart the result array as I loop through the result set and stuff the contents into a new array:
for($i=1; $i<=$num_rows; $i++) {
$arr = mysql_fetch_array($results);
$pkg[] = array("res1" => $arr[0], "res2" => $arr[1]);
}
Or is there an easier way?
For the server (where the function resides):
for($i=1; $i<=$num_rows; $i++) {
$arr = mysql_fetch_array($result);
$page[] = "$arr[0],$arr[1],$arr[2],$arr[3],$arr[4]";
}
return $page;
And on the client end I wrote:
$page = $soapclient->call('thefunction');
$num_rows = count($page);
for($i=0; $i<$num_rows; $i++) {
$arr = explode(",",$page[$i]);
echo "$arr[0] - $arr[1] - $arr[2] - $arr[3]<br />";
}
The formatting will be changed but I wanted something I could take apart and use.
On the server side I kept trying things like
$page[] = array($arr[0],$arr[1],...) thinking I'd be able to access it using a similar for loop and
$page[$i][0] - $page[$i][1] and so on - but it didn't work out. The var_dump gave me something that didn't make any sense so I opted for the brute force method.