4 * Oracle extensions for the ADODB DB backend.
5 * @author: Philippe.Vanhaesendonck@topgame.be
8 require_once 'lib/WikiDB/backend/ADODB.php';
10 class WikiDB_backend_ADODB_oci8po
11 extends WikiDB_backend_ADODB
18 function WikiDB_backend_ADODB_oci8po($dbparams)
20 // Lowercase Assoc arrays
21 define('ADODB_ASSOC_CASE', 0);
23 // Backend constructor
24 $this->WikiDB_backend_ADODB($dbparams);
26 // Empty strings are NULLS in Oracle
27 $this->_expressions['notempty'] = "IS NOT NULL";
29 $this->_expressions['iscontent'] = "DECODE(DBMS_LOB.GETLENGTH(content), NULL, 0, 0, 0, 1)";
31 $this->_prefix = isset($dbparams['prefix']) ? $dbparams['prefix'] : '';
39 // Do nothing here -- Leave that for the DBA
40 // Cost Based Optimizer tuning vary from version to version
47 * We don't really need to lock exclusive, but I'll relax it when I fully
48 * understand phpWiki locking ;-)
51 function _lock_tables($tables, $write_lock = true)
57 // Next line is default behaviour, so just skip it
58 // $dbh->Execute("SET TRANSACTION READ WRITE");
59 foreach ($tables as $table) {
60 if ($this->_prefix && !strstr($table, $this->_prefix)) {
61 $table = $this->_prefix . $table;
63 $dbh->Execute("LOCK TABLE $table IN EXCLUSIVE MODE");
66 // Just ensure read consistency
67 $dbh->Execute("SET TRANSACTION READ ONLY");
74 function _unlock_tables($tables)
77 $dbh->Execute("COMMIT WORK");
80 // Search callbacks (replaced by class below)
83 function _sql_match_clause($word) {
84 $word = preg_replace('/(?=[%_\\\\])/', "\\", $word);
85 $word = $this->_dbh->qstr("%$word%");
86 return "LOWER(pagename) LIKE $word";
90 // Fulltext -- case sensisitive :-\
91 // If we want case insensitive search, one need to create a Context
92 // Index on the CLOB. While it is very efficient, it requires the
93 // Intermedia Text option, so let's stick to the 'simple' thing
95 function _fullsearch_sql_match_clause($word) {
96 $word = preg_replace('/(?=[%_\\\\])/', "\\", $word);
97 $wordq = $this->_dbh->qstr("%$word%");
98 return "LOWER(pagename) LIKE $wordq "
99 . "OR DBMS_LOB.INSTR(content, '$word') > 0";
106 function _serialize($data)
110 assert(is_array($data));
111 return $this->_dbh->BlobEncode(serialize($data));
117 function _unserialize($data)
121 $d = $this->_dbh->BlobDecode($data);
122 if (!is_string($d)) {
125 return unserialize($this->_dbh->BlobDecode($data));
128 function write_accesslog(&$entry)
132 $log_tbl = $entry->_accesslog->logtable;
133 $dbh->query("INSERT INTO $log_tbl"
134 . " (time_stamp,remote_host,remote_user,request_method,request_line,request_uri,"
135 . "request_args,request_time,status,bytes_sent,referer,agent,request_duration)"
136 . " VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)",
138 // Problem: date formats are backend specific. Either use unixtime as %d (long),
139 // or the native timestamp format.
140 date('d-M-Y H:i:s', $entry->time),
143 $entry->request_method,
146 $entry->request_args,
147 $entry->_ncsa_time($entry->time),
157 class WikiDB_backend_ADODB_oci8_search
158 extends WikiDB_backend_ADODB_search
160 // If we want case insensitive search, one need to create a Context
161 // Index on the CLOB. While it is very efficient, it requires the
162 // Intermedia Text option, so let's stick to the 'simple' thing
163 // Note that this does only an exact fulltext search, not using MATCH or LIKE.
164 function _fulltext_match_clause($node)
166 if ($this->isStoplisted($node))
168 $page = $node->sql();
169 $exactword = $node->_sql_quote($node->word);
170 return ($this->_case_exact
171 ? "pagename LIKE '$page' OR DBMS_LOB.INSTR(content, '$exactword') > 0"
172 : "LOWER(pagename) LIKE '$page' OR DBMS_LOB.INSTR(content, '$exactword') > 0");
180 // c-hanging-comment-ender-p: nil
181 // indent-tabs-mode: nil