I am having an issue where the output from a MySQL stored procedure is not handled correctly, when there is NO resultset, as opposed to a NULL resultset. For example:
1) select * from myTable; //this works, there are 0,1, multiple records returned
2) select * from myTable where 1=2; //this works, there are 0 records returned in a NULL resultset
3) set user_level = 'user';
if user_level = 'admin' then
select * from myTable; //this never hits
end if;
There is an error in #3, the query is never touched, so NO resultset is returned. This is different from what happens in example #2, where a resultset is returned, it is just NULL.
My code looks like this:
if ( ($result = $mysqli_conn->query($SQL)) == false )
{
printf("Invalid query: %s\nWhole query: %s\n", $mysqli_conn->error, $SQL);
}
else {
while ($myrow = $result->fetch_array(MYSQLI_ASSOC))
{
... do something here
}
Any thoughts on how to handle this cleanly? Thanks all,
Frank