this is a variant of mysqli_query that returns output parameters as a rowset.
<?php
function mysqli_exec($link, $command)
{
$select = '';
$i2 = 0;
while (true)
{
$i1 = strpos($command, '@', $i2);
if ($i1 === false)
break;
$field = '';
$i2 = $i1 + 1;
while ($i2 < strlen($command) &&
($command[$i2] >= '0' && $command[$i2] <= '9') ||
($command[$i2] >= 'A' && $command[$i2] <= 'Z') ||
($command[$i2] >= 'a' && $command[$i2] <= 'z') ||
($command[$i2] == '_'))
$i2++;
$field = substr($command, $i1 + 1, $i2 - $i1 - 1);
if (strlen($select) == 0)
$select = "select @{$field} as $field";
else
$select = $select . ", @{$field} as $field";
}
if (strlen($select) > 0)
{
mysqli_query($link, $command);
return mysqli_query($link, $select);
}
else
return mysqli_query($link, $command);
}
?>
an example:
<?php
$link = mysqli_connect('localhost', 'myusr', 'mypass') or die ('Error connecting to mysql: ' . mysqli_error($link));
mysqli_select_db($link, 'clips');
$user_name = 'test';
$result = mysqli_exec($link, "call do_user_login('$user_name', @session_id, @msg)");
while ($row = mysqli_fetch_assoc($result))
{
echo "session_id : {$row['session_id']} <br>";
echo "msg : {$row['msg']} <br>";
}
?>