$db=mysql_connect($DBAddress,$DBUser,$DBPw);
mysql_select_db('MyDB',$db);
$LQuery ="SELECT * From myorders WHERE SOID = '$ShipperID' ";
$QResult = mysql_query($LQuery);
$ShipperInfo = mysql_fetch_object($QResult);
$CustomerOrder = utf8_encode($ShipperInfo->CustomerOrder);
$PhoneNumber = utf8_encode($ShipperInfo->PhoneNumber);
$Attention = utf8_encode($ShipperInfo->Attention);
... ect
and that by using a class I can have something like
class order{
public $ShippingOrder;
public $CustomerOrder;
public $PhoneNumber;
public $Attention;}
So that the a query might be returned as
$foundorder = new order;
$db=mysql_connect($DBAddress,$DBUser,$DBPw);
mysql_select_db('MyDB',$db);
$LQuery ="SELECT * From myorders WHERE SOID = '$ShipperID' ";
$QResult = mysql_query($LQuery);
$ShipperInfo = mysql_fetch_object($QResult);
$foundorder->SOID = utf8_encode($ShipperInfo->SOID);
$foundorder->CustomerOrder = utf8_encode($ShipperInfo->CustomerOrder);
$foundorder->PhoneNumber = utf8_encode($ShipperInfo->PhoneNumber);
$foundorder->Attention = utf8_encode($ShipperInfo->Attention);
... ect
But is their a better way to load the results from the fetch_object to the order class object ?
I.E. would
$foundorder = $QResult; work if they both have the same structure?
Also how would one do an Update to the database using a class object ?
$SQLQuery = "UPDATE `myorders` SET '$neworder' WHERE `OrderID`= '$myorders->OrderID' LIMIT 1";


Sign In
Create Account


Back to top









