<?php
class CountriesModel{
    /**
     * get the list of all countries
     * @return Array of countries
     */
    public function getAllCountries($getArray = false){
        global $database;

        $sql = "SELECT
                    id,
                    name
                FROM " . TABLES['countries']."
                ORDER BY name";

        $countriesArray = $database->fetchResultArray($sql);
        
        if($getArray) {
            return $countriesArray;
        }

        foreach($countriesArray as $countryInfo) {
            $countries[$countryInfo['id']] = $countryInfo['name'];
        }

        return $countries;
    }
}
?>
