<?php
class university_model {
    private $db;
    public function __construct() {
        $this->db = database::connect();
    }

    public function getAll() {
        return $this->db->query("SELECT a.*, b.symbol as currency_name, b.code FROM university a JOIN currency b ON a.currency = b.id")->fetch(PDO::FETCH_ASSOC);
    }

    public function update($data) {
        $fields = implode(',', array_map(fn($k) => "$k = ?", array_keys($data)));
        $stmt = $this->db->prepare("UPDATE university SET $fields");
        return $stmt->execute([...array_values($data)]);
    }

}
?>
