| 1234567891011121314151617181920212223 |
- <?php
- namespace Models;
- class HarvestModel
- {
- private \PDO $pdo;
- public function __construct()
- {
- if (!isset($GLOBALS['pdo']) || !$GLOBALS['pdo'] instanceof \PDO) {
- throw new \RuntimeException('Global PDO connection not initialized');
- }
- $this->pdo = $GLOBALS['pdo'];
- }
- public function getAll(): array
- {
- $stmt = $this->pdo->query('SELECT harvest_code, harvest_name FROM "harvest" ORDER BY harvest_name');
- return $stmt->fetchAll(\PDO::FETCH_ASSOC) ?: [];
- }
- }
|