Ok I am having some struggles with getting multiple stored procedures to run together. I know you are supposed to free the results of each SP and check for additional resultset(s) and free those as well before running another query. I believe I am doing that and I am still not having any luck with it…function is below.
[code=php]
function scoreQuestion($tID, $qID)
{
$score = 0;
$sql = “CALL sProcedure()”;
if ($mysqli->query($sql))
{
do {
/* store first result set */
if ($result = $mysqli->use_result())
{
$x = 0;
while ($row = $result->fetch_row())
{
$aIDArr[$x] = $row[3];
$x++;
}
var_dump($result);
$result->free();
}
} while ($mysqli->next_result());
}
for($i = 0; $i < count($aIDArr); $i++)
{
$sql = “CALL secondProcedure()”;
$mysqli->query($sql);
$result = $mysqli->use_result(); //var_dump($result) returns bool(false)…even though I believe I have cleared the results already.
while($row = $result->fetch_row()) //Error occurs here
{
$score = $score + $row[0];
}
$result->close();
}
return (int)$score;
}
Any help would be greatly appreciated!