36 lines
799 B
PHP
Raw Permalink Normal View History

2023-01-24 19:00:39 +01:00
<?php
class _list {
protected $entity = "";
protected $PDO;
public function __construct() {
global $PDO;
$this->PDO = $PDO;
$this->PDO->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
public function listAll() {
// returns an array of all
try {
$stmt = $this->PDO->prepare("SELECT id, name FROM l_" .$this->entity ." ORDER BY name ASC");
$stmt->execute();
if ($r = $stmt->fetchAll(PDO::FETCH_ASSOC)) {
return $r;
}
}
catch (exception $ex) {
common::except ('Err: ' .$ex .' in ' .__DIR__ .'/' .__FILE__ .':' .__LINE__);
return false;
}
}
}