4 * Oracle extensions for the Pear DB backend.
5 * @author: Philippe.Vanhaesendonck@topgame.be
8 require_once 'lib/WikiDB/backend/PearDB_pgsql.php';
10 class WikiDB_backend_PearDB_oci8
11 extends WikiDB_backend_PearDB_pgsql
13 function __construct($dbparams)
15 // Backend constructor
16 parent::__construct($dbparams);
17 if (DB::isError($this->_dbh)) return;
19 // Empty strings are NULLS
20 $this->_expressions['notempty'] = "IS NOT NULL";
21 $this->_expressions['iscontent'] = "DECODE(DBMS_LOB.GETLENGTH(content), NULL, 0, 0, 0, 1)";
25 // - No persistent conections (I don't like them)
26 $dbh->setOption('persistent', false);
27 // - Set lowercase compatibility option
28 // - Set numrows as well -- sure why this is needed, but some queries
29 // are triggering DB_ERROR_NOT_CAPABLE
30 $dbh->setOption('portability',
31 DB_PORTABILITY_LOWERCASE | DB_PORTABILITY_NULL_TO_EMPTY | DB_PORTABILITY_NUMROWS);
39 // Do nothing here -- Leave that for the DBA
40 // Cost Based Optimizer tuning vary from version to version
45 * Lock all tables we might use.
47 function _lock_tables($write_lock = true)
51 // Not sure if we really need to lock tables here, the Oracle row
52 // locking mechanism should be more than enough
53 // For the time being, lets stay on the safe side and lock...
55 // Next line is default behaviour, so just skip it
56 // $dbh->query("SET TRANSACTION READ WRITE");
57 foreach ($this->_table_names as $table) {
58 $dbh->query("LOCK TABLE $table IN EXCLUSIVE MODE");
61 // Just ensure read consistency
62 $dbh->query("SET TRANSACTION READ ONLY");
68 return base64_encode($s);
73 return base64_decode($s);
76 function write_accesslog(&$entry)
80 $log_tbl = $entry->_accesslog->logtable;
81 // duration problem: sprintf "%f" might use comma e.g. "100,201" in european locales
82 $dbh->query("INSERT INTO $log_tbl"
83 . " (time_stamp,remote_host,remote_user,request_method,request_line,request_uri,"
84 . "request_args,request_time,status,bytes_sent,referer,agent,request_duration)"
85 . " VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)",
87 // Problem: date formats are backend specific. Either use unixtime as %d (long),
88 // or the native timestamp format.
89 date('d-M-Y H:i:s', $entry->time),
92 $entry->request_method,
96 $entry->_ncsa_time($entry->time),
106 class WikiDB_backend_PearDB_oci8_search
107 extends WikiDB_backend_PearDB_search
109 // If we want case insensitive search, one need to create a Context
110 // Index on the CLOB. While it is very efficient, it requires the
111 // Intermedia Text option, so let's stick to the 'simple' thing
112 // Note that this does only an exact fulltext search, not using MATCH or LIKE.
113 function _fulltext_match_clause($node)
115 if ($this->isStoplisted($node))
117 $page = $node->sql();
118 $exactword = $node->sql_quote($node->word);
119 return ($this->_case_exact
120 ? "pagename LIKE '$page' OR DBMS_LOB.INSTR(content, '$exactword') > 0"
121 : "LOWER(pagename) LIKE '$page' OR DBMS_LOB.INSTR(content, '$exactword') > 0");
129 // c-hanging-comment-ender-p: nil
130 // indent-tabs-mode: nil