(airhead): ive no idea no lie

Signed-off-by: boris <boris@borishub.co.uk>
This commit is contained in:
boris
2024-12-04 21:13:46 +00:00
parent 5b0d04b702
commit 8de2b7f29e
32 changed files with 233 additions and 1103 deletions

View File

@@ -9,6 +9,12 @@ class UserDataSet {
$this->_dbInstance = Database::getInstance();
$this->_dbHandle = $this->_dbInstance->getDbConnection();
}
/**
* @param $username
* @return mixed
* Query access level of a username, and return their usertype
*/
public function checkAccessLevel($username) {
$sqlQuery = "SELECT ecoUser.userType FROM ecoUser
LEFT JOIN ecoUsertypes ON ecoUser.userType = ecoUsertypes.userType
@@ -18,26 +24,12 @@ class UserDataSet {
$statement->execute();
return $statement->fetch(PDO::FETCH_ASSOC)['userType'];
}
public function fetchAll(): array
{
$sqlQuery = 'SELECT * FROM ecoUser;';
$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 UserData($row);
}
return $dataSet;
}
/**
* @param $username
* @param $password
* @return array
* Authenticate user with query, and return their details
*/
public function checkUserCredentials($username, $password): array
{
@@ -52,16 +44,4 @@ class UserDataSet {
}
return $dataSet;
}
public function fetchUser($username): array
{
$sqlQuery = 'SELECT * FROM ecoUser WHERE username = ?';
$statement = $this->_dbHandle->prepare($sqlQuery);
$statement->execute([$username]);
$dataSet = [];
while ($row = $statement->fetch()) {
$dataSet[] = new UserData($row);
}
return $dataSet;
}
}