web / app /Models /Model.php
souliya_pps
first commit
7731906
Raw History Blame Contribute Delete
524 Bytes
<?php
namespace App\Models;
use App\Core\Database;
abstract class Model {
protected $db;
protected $table;
public function __construct() {
$this->db = Database::getInstance();
}
public function all() {
$stmt = $this->db->query("SELECT * FROM {$this->table}");
return $stmt->fetchAll();
}
public function find($id) {
$stmt = $this->db->prepare("SELECT * FROM {$this->table} WHERE id = ?");
$stmt->execute([$id]);
return $stmt->fetch();
}
}