add template files and compose file, fix syntax errors in template
This commit is contained in:
30
Models/FacilityDataSet.php
Normal file
30
Models/FacilityDataSet.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
require_once ('Database.php');
|
||||
require_once ('FacilityData.php');
|
||||
|
||||
class FacilityDataSet {
|
||||
protected $_dbHandle, $_dbInstance;
|
||||
|
||||
public function __construct() {
|
||||
$this->_dbInstance = Database::getInstance();
|
||||
$this->_dbHandle = $this->_dbInstance->getDbConnection();
|
||||
}
|
||||
|
||||
public function fetchAll(): array
|
||||
{
|
||||
$sqlQuery = 'SELECT * FROM ecoFacilities;';
|
||||
|
||||
$statement = $this->_dbHandle->prepare($sqlQuery); // prepare a PDO statement
|
||||
$statement->execute(); // execute the PDO statement
|
||||
|
||||
$dataSet = [];
|
||||
// loop through and read the results of the query and cast
|
||||
// them into a matching object
|
||||
while ($row = $statement->fetch()) {
|
||||
$dataSet[] = new FacilityData($row);
|
||||
}
|
||||
return $dataSet;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user