3 require_once 'lib/WikiDB.php';
6 * WikiDB layer for ADODB, which does nothing more than calling the
7 * mysql-specific ADODB backend.
8 * Support for a newer adodb library, the adodb extension library
9 * and more databases will come with PhpWiki v1.3.10
11 * @author: Lawrence Akka, Reini Urban
13 class WikiDB_ADODB extends WikiDB
15 function WikiDB_ADODB($dbparams)
18 if (is_array($dbparams['dsn']))
19 $backend = $dbparams['dsn']['phptype'];
20 elseif (preg_match('/^(\w+):/', $dbparams['dsn'], $m))
22 // Do we have a override? (currently: mysql, sqlite, oracle, mssql, oci8po, postgres7)
23 // TODO: mysqlt (innodb or bdb)
24 if ($backend == 'pgsql') { // PearDB DSN cross-compatiblity hack (for unit testing)
25 $backend = 'postgres7';
26 if (is_string($dbparams['dsn']))
27 $dbparams['dsn'] = $backend . ':' . substr($dbparams['dsn'], 6);
29 if (FindFile("lib/WikiDB/backend/ADODB_" . $backend . ".php", true)) {
30 $backend = 'ADODB_' . $backend;
34 include_once 'lib/WikiDB/backend/' . $backend . '.php';
35 $backend_class = "WikiDB_backend_" . $backend;
36 $backend = new $backend_class($dbparams);
37 if (!$backend->_dbh->_connectionID) return false;
38 $this->WikiDB($backend, $dbparams);
42 * Determine whether page exists (in non-default form).
43 * @see WikiDB::isWikiPage
45 function isWikiPage($pagename)
47 $pagename = (string)$pagename;
48 if ($pagename === '') return false;
49 if (!array_key_exists($pagename, $this->_cache->_id_cache)) {
50 $this->_cache->_id_cache[$pagename] = $this->_backend->is_wiki_page($pagename);
52 return $this->_cache->_id_cache[$pagename];
55 // add surrounding quotes '' if string
58 if (is_int($in) || is_double($in)) {
60 } elseif (is_bool($in)) {
62 } elseif (is_null($in)) {
65 return $this->_backend->_dbh->qstr($in);
69 // ADODB handles everything as string
70 // Don't add surrounding quotes '', same as in PearDB
73 return $this->_backend->_dbh->addq($in);
79 if (!$request->_dbi) return false;
80 return is_resource($this->_backend->connection());
83 // SQL result: for simple select or create/update queries
84 // returns the database specific resource type
85 function genericSqlQuery($sql, $args = false)
88 $result = $this->_backend->_dbh->Execute($sql, $args);
90 $result = $this->_backend->_dbh->Execute($sql);
92 trigger_error("SQL Error: " . $this->_backend->_dbh->ErrorMsg(), E_USER_WARNING);
99 // SQL iter: for simple select or create/update queries
100 // returns the generic iterator object (count,next)
101 function genericSqlIter($sql, $field_list = NULL)
103 $result = $this->genericSqlQuery($sql);
104 return new WikiDB_backend_ADODB_generic_iter($this->_backend, $result, $field_list);
113 // c-hanging-comment-ender-p: nil
114 // indent-tabs-mode: nil