DSN-Parsing not suitable for Firebird
- Status
- Closed
- Subject
- DSN-Parsing not suitable for Firebird
- Version
- 9.x
- Category
- Error
- Feature
- Database independence (Non-Mysql, ADOdb Postgres, Oracle, etc)
- Resolution status
- Out of Date
- Submitted by
- chaosben
- Lastmod by
- Ushindi Gedeon
- Rating
- Description
get_dsn_info and get_db_by_name doesnt support a connection to firebird because they firebird-connection-string is a little bit special (no host, everthing inside the dbname).
The solution contains also code for using params in the connectionstring.
- Solution
- get_dsn_infoCopy to clipboardfunction get_dsn_info($name) { $info = array(); $dsnsqlplugin = $this->get_dsn_by_name($name); $parsedsn = $dsnsqlplugin; $info['driver'] = strtok($parsedsn, ":"); $parsedsn = substr($parsedsn, strlen($info['driver']) + 3); $info['user'] = strtok($parsedsn, ":"); $parsedsn = substr($parsedsn, strlen($info['user']) + 1); $info['password'] = strtok($parsedsn, "@"); $parsedsn = substr($parsedsn, strlen($info['password']) + 1); if ($info['driver'] == 'firebird') { $info['host'] = null; } else { $info['host'] = strtok($parsedsn, "/"); $parsedsn = substr($parsedsn, strlen($info['host']) + 1); } $info['database'] = strtok($parsedsn, "?"); $parsedsn = substr($parsedsn, strlen($info['database']) + 1); $info['params'] = array(); while (strlen($parsedsn) > 0) { $param = strtok($parsedsn, "&"); $parsedsn = substr($parsedsn, strlen($param) + 1); $paramname = strtok($param, "="); $paramvalue = substr($param, strlen($paramname) + 1); $info['params'][$paramname] = $paramvalue; } return $info; }get_db_by_nameCopy to clipboardfunction get_db_by_name( $name ) { include_once ('tiki-setup.php'); if ( $name == 'local' || empty($name) ) { return TikiDb::get(); } try { static $connectionMap = array(); if ( ! isset( $connectionMap[$name] ) ) { $connectionMap[$name] = false; $info = $this->get_dsn_info($name); $dbdriver = $info['driver']; $dbuserid = $info['user']; $dbpassword = $info['password']; $dbhost = $info['host']; $database = $info['database']; $params = $info['params']; $api_tiki = null; require 'db/local.php'; if (isset($api_tiki) && $api_tiki == 'adodb') { require_once ('lib/adodb/adodb.inc.php'); $dbsqlplugin = ADONewConnection($dbdriver); if ( $dbsqlplugin->NConnect($dbhost, $dbuserid, $dbpassword, $database) ) { $connectionMap[$name] = new TikiDb_AdoDb($dbsqlplugin); } } else { $connstr = $dbdriver.':'.(($dbhost)?'host='.$dbhost.';':'').'dbname='.$database; foreach($params as $name=>$value) $connstr .= ";$name=$value"; $dbsqlplugin = new PDO($connstr, $dbuserid, $dbpassword); $connectionMap[$name] = new TikiDb_Pdo($dbsqlplugin); } } return $connectionMap[$name]; } catch (Exception $e) { TikiLib::lib('errorreport')->report($e->getMessage()); } }
- Workaround
- Importance
- 3
- Priority
- 15
- Demonstrate Bug on Tiki 19+
-
This bug has been demonstrated on show2.tiki.org
Please demonstrate your bug on show2.tiki.org
Show.tiki.org is not configured properlyThe public/private keys configured to connect to show2.tiki.org were not accepted. Please make sure you are using RSA keys. Thanks.
- Demonstrate Bug (older Tiki versions)
-
This bug has been demonstrated on show.tikiwiki.org
Please demonstrate your bug on show.tikiwiki.org
Show.tiki.org is not configured properlyThe public/private keys configured to connect to show.tikiwiki.org were not accepted. Please make sure you are using RSA keys. Thanks.
- Ticket ID
- 4322
- Created
- Thursday 25 October, 2012 13:20:03 UTC
by chaosben - LastModif
- Saturday 04 July, 2026 21:08:44 UTC