conn->prepare("SELECT * FROM orders ORDER BY id DESC LIMIT :limit"); $stmt->bindValue(':limit', $limit, \PDO::PARAM_INT); $stmt->execute(); return $stmt->fetchAll(); } public function countAll() { $stmt = $this->conn->query("SELECT COUNT(*) as total FROM orders"); return $stmt->fetch()['total']; } public function countRecent($days = 7) { $stmt = $this->conn->prepare("SELECT COUNT(*) as total FROM orders WHERE created_at >= DATE_SUB(NOW(), INTERVAL :days DAY)"); $stmt->bindValue(':days', $days, \PDO::PARAM_INT); $stmt->execute(); return $stmt->fetch()['total']; } public function getLastOrderDate() { $stmt = $this->conn->query("SELECT created_at FROM orders ORDER BY id DESC LIMIT 1"); $result = $stmt->fetch(); return $result ? $result['created_at'] : null; } }