Spaces:
Running
Running
Download app/Models/Model.php from buddhaword/web: direct link, hf CLI and curl.
- Browser
- Download file 524 Bytes
-
https://huggingface.co/spaces/buddhaword/web/resolve/main/app/Models/Model.php
- Command line
-
hf download hf://spaces/buddhaword/web/app/Models/Model.php
-
curl -L -o Model.php https://huggingface.co/spaces/buddhaword/web/resolve/main/app/Models/Model.php
524 Bytes
| 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(); | |
| } | |
| } | |