I’m probably missing some thing obvious but the constructor is not firing with new object. I’ve been pulling my hair out for hours. I did check I am getting results from the query.
The beginning of the class
class OrderDetail {
private $id;
private $product;
private $quanity;
private $price;
private $orderID;
private $noProduction;
private $productName;
public function _construct($orderID, $id = NULL, $product = NULL, $productName = NULL, $quanity = NULL, $price = NULL, $noProduction = NULL){
$this->id = $id;
$this->orderID = $orderID;
echo "check";
$this->product = $product;
$this->productName=$productName;
$this->quanity = $quanity;
$this->price = $price;
$this->noProduction = $noProduction;
}
The function that should create a new object
public static function getOrderDetails($orderID){
$db= database_connection::getDB();
$query = "SELECT tblorder_details.*, tblproduct.product_name
FROM tblorder_details INNER JOIN tblproduct ON tblorder_details.product_ID = tblproduct.product_ID
WHERE (((tblorder_details.order_ID)= :orderID))";
$statement = $db->prepare($query);
$statement->bindValue(':orderID', $orderID);
$statement->execute();
$orderDetails = array();
foreach ($statement as $row){
//echo $row["order_ID"];
$orderDetail = new OrderDetail(
$row["order_ID"],
$row["order_details_ID"],
$row["product_ID"],
$row["product_name"],
$row["quanity"],
$row["price"],
$row["no_production"]);
$orderDetails[]=$orderDetail;
}
return $orderDetails;
}
You need two __