This commit is contained in:
Joshua Perry 2023-02-04 21:55:07 +00:00
parent c8548122cd
commit 650e678d9b
2 changed files with 6 additions and 6 deletions

View File

@ -36,12 +36,12 @@ class DatabaseTable {
$this->pdo->prepare('UPDATE '. $this->table .' SET '. \implode(', ', $params) .' WHERE '. $this->pk .' = :primaryKey')->execute($record);
}
public function find($column, $value, $column2 = "", $value2 = "", $comparator = "=", $order = "ASC") {
if ($column2 == "" && $value2 == "") {
public function find($column, $value, $column2 = "", $value2 = "", $comparator = "=", $comparator2 = "=", $order = "ASC", $orderColumn = "id") {
if ($column2 == "" || $value2 == "") {
$values = [
'value' => $value
];
$stmt = $this->pdo->prepare('SELECT * FROM '. $this->table . ' WHERE '. $column . ' '. $comparator .' :value ORDER BY '. $column ." ". $order);
$stmt = $this->pdo->prepare('SELECT * FROM '.$this->table.' WHERE '.$column.' '.$comparator.' :value ORDER BY '.$orderColumn." ".$order);
$stmt->setFetchMode(\PDO::FETCH_CLASS, $this->entityClass, $this->entityConstructor);
$stmt->execute($values);
return $stmt->fetchAll();
@ -51,7 +51,7 @@ class DatabaseTable {
'value' => $value,
'value2' => $value2
];
$stmt = $this->pdo->prepare('SELECT * FROM '. $this->table . ' WHERE '. $column . ' '. $comparator .' :value AND '. $column2 .' = :value2');
$stmt = $this->pdo->prepare('SELECT * FROM '.$this->table.' WHERE '.$column.' '.$comparator.' :value AND '.$column2.' '.$comparator2.' :value2 ORDER BY '.$orderColumn." ".$order);
$stmt->setFetchMode(\PDO::FETCH_CLASS, $this->entityClass, $this->entityConstructor);
$stmt->execute($values);
return $stmt->fetchAll();

View File

@ -14,7 +14,7 @@ class Jobs {
}
public function home() {
$this->vars['jobs'] = $this->jobsTable->find("closingDate", date("y-m-d"), "", "", ">", "DESC");
$this->vars['jobs'] = $this->jobsTable->find("closingDate", date("y-m-d"), "", "", ">", "", "DESC", "closingDate");
return ['template' => 'home.html.php',
'title' => 'Jo\'s Jobs- Home',
'vars' => $this->vars
@ -31,7 +31,7 @@ class Jobs {
$this->vars['jobs'] = $this->jobsTable->find('categoryId', $cat[0]->id, "location", $_GET['filter']);
}
else {
$this->vars['jobs'] = $this->jobsTable->find('categoryId', $cat[0]->id);
$this->vars['jobs'] = $this->jobsTable->find('categoryId', $cat[0]->id, "closingDate", date("y-m-d"), "=", ">");
}
$this->vars['heading'] = $cat[0]->name;