Files
_resources/it114105/itp4513/Assignment/19-20/controllers/Store.php
louiscklaw 04dbefcbaf update,
2025-02-01 01:58:47 +08:00

33 lines
1.1 KiB
PHP

<?php
class Store extends Controller{
private $database;
function __construct(){
if(isset($_GET['id'])){
$this->database = new DatabaseAccess();
$consignmentStoreID = $_GET['id'];
$storeItemList = $this->getStoreItem($consignmentStoreID);
$storeInf = $this->getStoreName($consignmentStoreID);
$consignmentStore = new ConsignmentStore($storeInf[0], $storeInf[1], $storeItemList);
parent::__construct("Store", $consignmentStore);
}else{
header('Location: home');
}
}
public function getStoreItem($consignmentStoreID){
$result = $this->database->query("SELECT * FROM Goods WHERE consignmentStoreID = ?", "s", array($consignmentStoreID));
return $result;
}
public function getStoreName($consignmentStoreID){
$result = $this->database->query("SELECT consignmentStoreID, ConsignmentStoreName FROM ConsignmentStore WHERE consignmentStoreID = ?", "s", array($consignmentStoreID));
$row = $result->fetch_array(MYSQLI_ASSOC);
return array($row["consignmentStoreID"], $row["ConsignmentStoreName"]);
}
}
?>