| 123456789101112131415161718192021222324252627 |
- <?php
- namespace Models;
- class StatusModel
- {
- private \PDO $pdo;
- public function __construct()
- {
- if (isset($GLOBALS['pdo']) && $GLOBALS['pdo'] instanceof \PDO) {
- $this->pdo = $GLOBALS['pdo'];
- return;
- }
- throw new \RuntimeException('Global PDO connection not initialized');
- }
- public function getIdByStatus(string $status): ?int
- {
- $stmt = $this->pdo->prepare('SELECT status_id FROM "status" WHERE LOWER(status_status) = LOWER(:status) LIMIT 1');
- $stmt->execute(['status' => $status]);
- $id = $stmt->fetchColumn();
- return $id === false ? null : (int)$id;
- }
- }
|