diff --git a/README.md b/README.md index c702fa6..25836ef 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,10 @@ A dokuwiki plugin for processing query to MySQL databases and display results as a table. This is a improved version which cann connect to different hosts -and databases. The default host and database is set in the plugin -configuration. -Different hosts and databases can be set inside the tag: +and databases. The defaults are set in the plugin configuration. +Different types, hosts and databases can be set inside the tag: ``` - + SELECT foo FROM bar ORDER BY baz ``` diff --git a/conf/default.php b/conf/default.php index 5ba9faa..d8e33f6 100644 --- a/conf/default.php +++ b/conf/default.php @@ -7,6 +7,7 @@ //$conf['fixme'] = 'FIXME'; +$conf['type'] = 'mysql'; $conf['Host'] = 'localhost'; $conf['DB'] = ''; $conf['user'] = ''; diff --git a/conf/metadata.php b/conf/metadata.php index 2f183c1..b32eb9e 100644 --- a/conf/metadata.php +++ b/conf/metadata.php @@ -5,7 +5,7 @@ * @author George Pirogov */ - +$meta['type'] = array('multichoice', '_choices' => array('mysql', 'dblib')); $meta['Host'] = array('string'); $meta['DB'] = array('string'); $meta['user'] = array('string'); diff --git a/lang/de/settings.php b/lang/de/settings.php index 4db9d53..202e191 100644 --- a/lang/de/settings.php +++ b/lang/de/settings.php @@ -7,6 +7,7 @@ // keys need to match the config setting name +$lang['type'] = 'DSN-Prefix (Datenbanktyp)'; $lang['Host'] = 'Standard MySQL-Serveradresse (DNS or IP)'; $lang['DB'] = 'Standard MySQL-Datenbankname'; $lang['user'] = 'Datenbankbenutzername'; diff --git a/lang/en/settings.php b/lang/en/settings.php index 61daf96..476f0de 100644 --- a/lang/en/settings.php +++ b/lang/en/settings.php @@ -8,6 +8,7 @@ // keys need to match the config setting name // $lang['fixme'] = 'FIXME'; +$lang['type'] = 'DSN prefix (database type)'; $lang['Host'] = 'Default MySQL server address (DNS or IP)'; $lang['DB'] = 'MySQL database name'; $lang['user'] = 'Database username'; diff --git a/lang/ru/settings.php b/lang/ru/settings.php index 00669a1..8407be5 100644 --- a/lang/ru/settings.php +++ b/lang/ru/settings.php @@ -8,6 +8,7 @@ // keys need to match the config setting name // $lang['fixme'] = 'FIXME'; +$lang['type'] = 'Префикс DSN (тип базы данных)'; $lang['Host'] = 'Адрес MySQL сервера по умолчанию (DNS или IP)'; $lang['DB'] = 'Имя базы данных MySQL по умолчанию'; $lang['user'] = 'Логин'; diff --git a/syntax.php b/syntax.php index f379b68..7bc0c75 100644 --- a/syntax.php +++ b/syntax.php @@ -23,7 +23,7 @@ class syntax_plugin_sqlquery extends DokuWiki_Syntax_Plugin { public function connectTo($mode) { - $this->Lexer->addSpecialPattern('(?:.*?)', $mode, 'plugin_sqlquery'); + $this->Lexer->addSpecialPattern('(?:.*?)', $mode, 'plugin_sqlquery'); } /** @@ -39,6 +39,12 @@ class syntax_plugin_sqlquery extends DokuWiki_Syntax_Plugin { public function handle($match, $state, $pos, Doku_Handler $handler) { $data = array('state' => $state); if ($state == DOKU_LEXER_SPECIAL) { + # get type (DSN prefix) + if (preg_match('/getConf('type'); + } # get host if (preg_match('/getConf('password'); // connect to database - $dsn = "mysql:host={$data['host']};dbname={$data[db]}"; + $dsn = "{$data['type']}:host={$data['host']};dbname={$data[db]}"; try { $dbh = new PDO($dsn, $user, $password); } catch (PDOException $e) {