Exemplo n.º 1
0
 /**
  * Prepare database connection.
  * 
  * @param string $dsn (default = SETTINGS_DSN)
  * @param map $opt (default = [ 'table' => 'language', 'language' => SETTINGS_LANGUAGE, 'default' => 'txt' ])
  * @param string $language (default = SETTINGS_LANGUAGE)
  */
 public function setDSN($dsn = SETTINGS_DSN, $opt = ['table' => 'language', 'use' => SETTINGS_LANGUAGE, 'default' => 'txt'])
 {
     $this->db = Database::getInstance($dsn);
     $query_map = ['@query_prefix' => '', 'escape_name@table' => $opt['table'], 'escape_name@use' => $opt['use'], 'escape_name@default' => $opt['default'], 'select' => "SELECT {:=@use} AS lang, {:=@default} AS default, txt FROM {:=@table} WHERE id='{:=id}'", 'insert' => "INSERT INTO {:=@table} (id, lchange, txt) VALUES ('{:=id}', NOW(), '{:=txt}')", 'delete' => "DELETE FROM {:=@table} WHERE id='{:=id}'"];
     $this->db->setQueryHash($query_map);
     $this->createTable($opt['table']);
 }