私はおそらく明らかなことを見逃していますが、コンストラクターは新しいオブジェクトで起動していません。私は何時間も髪を引っ張っています。クエリから結果が得られていることを確認しました。クラスの始まり
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;
}
新しいオブジェクトを作成する関数
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;
}