db = new Database; } // Get all contact messages public function getMessages(){ $this->db->query('SELECT * FROM contact_messages ORDER BY created_at DESC'); return $this->db->resultSet(); } // Get messages with pagination public function getMessagesPaginated($limit, $offset){ $this->db->query('SELECT * FROM contact_messages ORDER BY created_at DESC LIMIT :limit OFFSET :offset'); $this->db->bind(':limit', $limit); $this->db->bind(':offset', $offset); return $this->db->resultSet(); } // Get total count of messages public function getMessagesCount(){ $this->db->query('SELECT COUNT(*) as count FROM contact_messages'); $row = $this->db->single(); return $row ? $row->count : 0; } // Get contact message by ID public function getMessageById($id){ $this->db->query('SELECT * FROM contact_messages WHERE id = :id'); $this->db->bind(':id', $id); return $this->db->single(); } // Add Contact Message public function addMessage($data){ $this->db->query('INSERT INTO contact_messages (name, email, subject, message) VALUES (:name, :email, :subject, :message)'); $this->db->bind(':name', $data['name']); $this->db->bind(':email', $data['email']); $this->db->bind(':subject', $data['subject']); $this->db->bind(':message', $data['message']); if($this->db->execute()){ return true; } else { return false; } } // Delete Contact Message public function deleteMessage($id){ $this->db->query('DELETE FROM contact_messages WHERE id = :id'); $this->db->bind(':id', $id); if($this->db->execute()){ return true; } else { return false; } } }