. */ /** * Theme Database Access Object. This class provides functionality to * load and save countries */ require_once(FILESYSTEMROOTPATH."include/classes/IDao.php"); require_once(FILESYSTEMROOTPATH."events/include/model/Theme.php"); class ThemeDao implements IDao { /** MySQL object */ private $mysql; /** * Default constructor */ public function __construct(MySQL $mysql) { $this->mysql = $mysql; } /** * Load a theme by id * * @param string name of the theme to be loaded * @return Theme containing the data of the requested theme, or NULL in case theme does not exist */ public function load($id) { $query = "SELECT `id`, `name`, `active`, `description` FROM ". EVENTS_MYSQL_DB. ".`themes` WHERE `id`='".$id."'"; if( $this->mysql->query($query) ) { return new Theme ($this->mysql->fetchArray()); }else { return array(); } } /** * Load all active themes * * @return array of Theme */ public function loadActive() { $query = "SELECT `id`, `name`, `active`, `description` FROM ". EVENTS_MYSQL_DB. ".`themes` WHERE `active`='1' ORDER BY `name`"; if( $this->mysql->query($query) ) { $ret = array(); while( $row = $this->mysql->fetchArray() ) { $ret[ $row['id'] ] = new Theme($row); } return $ret; }else { return array(); } } /** * Load all themes * * @return array of Theme */ public function loadAll() { $query = "SELECT `id`, `name`, `active`, `description` FROM ". EVENTS_MYSQL_DB. ".`themes` ORDER BY `active` DESC, `name`"; if( $this->mysql->query($query) ) { $ret = array(); while( $row = $this->mysql->fetchArray() ) { $ret[ $row['id'] ] = new Theme($row); } return $ret; }else { return array(); } } /** * Save or update a theme * * @param Theme object with the theme data * @return boolean true in case of success, false otherwise */ public function saveOrUpdate(IModel $theme) { } } ?>