I have the following sql and code which will return either a null set or a single row with one column.
Code: Select all
$sqlGetOrderID = "SELECT `Order_Id` FROM `Order` WHERE `Session_Id` = '$seshID'";
$result = mysql_query($sqlGetOrderID);
$row = mysql_fetch_object($result);
if($row->Order_Id <> "") { $orderID = $row->Order_Id; }
else $orderID = -1;
Being very new to this, I'm wondering if there is a cleaner, shorter, or more elegant way to check if there is a result set and set the variable to either the return value or -1. This seams like a lot of code to check for a single return value.
Any thoughts would be much appreciated.
Thanks!