]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/WikiDB/backend/PearDB_oci8.php
reorder deletion
[SourceForge/phpwiki.git] / lib / WikiDB / backend / PearDB_oci8.php
1 <?php // -*-php-*-
2 rcs_id('$Id: PearDB_oci8.php,v 1.12 2006-12-22 00:27:37 rurban Exp $');
3
4 /**
5  * Oracle extensions for the Pear DB backend.
6  * @author: Philippe.Vanhaesendonck@topgame.be
7  */
8
9 require_once('lib/WikiDB/backend/PearDB_pgsql.php');
10
11 class WikiDB_backend_PearDB_oci8
12 extends WikiDB_backend_PearDB_pgsql
13 {
14     /**
15      * Constructor
16      */
17     function WikiDB_backend_PearDB_oci8($dbparams) {
18         // Backend constructor
19         $this->WikiDB_backend_PearDB($dbparams);
20         
21         // Empty strings are NULLS
22         $this->_expressions['notempty'] = "IS NOT NULL";
23         $this->_expressions['iscontent'] = "DECODE(DBMS_LOB.GETLENGTH(content), NULL, 0, 0, 0, 1)";
24
25         // Set parameters:
26         $dbh = &$this->_dbh;
27         // - No persistent conections (I don't like them)
28         $dbh->setOption('persistent', false);
29         // - Set lowercase compatibility option
30         // - Set numrows as well -- sure why this is needed, but some queries 
31         //   are triggering DB_ERROR_NOT_CAPABLE
32         $dbh->setOption('portability',
33             DB_PORTABILITY_LOWERCASE | DB_PORTABILITY_NULL_TO_EMPTY | DB_PORTABILITY_NUMROWS);
34     }
35
36      * Pack tables.
37      */
38     function optimize() {
39         // Do nothing here -- Leave that for the DBA
40         // Cost Based Optimizer tuning vary from version to version
41         return 1;
42     }
43
44     /**
45      * Lock all tables we might use.
46      */
47     function _lock_tables($write_lock=true) {
48         $dbh = &$this->_dbh;
49         
50         // Not sure if we really need to lock tables here, the Oracle row
51         // locking mechanism should be more than enough
52         // For the time being, lets stay on the safe side and lock...
53         if ($write_lock) {
54             // Next line is default behaviour, so just skip it
55             // $dbh->query("SET TRANSACTION READ WRITE");
56             foreach ($this->_table_names as $table) {
57                 $dbh->query("LOCK TABLE $table IN EXCLUSIVE MODE");
58             }
59         } else {
60             // Just ensure read consistency
61             $dbh->query("SET TRANSACTION READ ONLY");
62         }
63     }
64
65     function _quote($s) {
66         return base64_encode($s);
67     }
68
69     function _unquote($s) {
70         return base64_decode($s);
71     }
72
73 };
74
75 class WikiDB_backend_PearDB_oci8_search
76 extends WikiDB_backend_PearDB_search
77 {
78     // If we want case insensitive search, one need to create a Context
79     // Index on the CLOB. While it is very efficient, it requires the
80     // Intermedia Text option, so let's stick to the 'simple' thing
81     // Note that this does only an exact fulltext search, not using MATCH or LIKE.
82     function _fulltext_match_clause($node) {
83         if ($this->isStoplisted($node))
84             return "1=1";
85         $page = $node->sql();
86         $exactword = $node->_sql_quote($node->word);
87         return ($this->_case_exact
88                 ? "pagename LIKE '$page' OR DBMS_LOB.INSTR(content, '$exactword') > 0"
89                 : "LOWER(pagename) LIKE '$page' OR DBMS_LOB.INSTR(content, '$exactword') > 0");
90     }
91 }
92
93 // $Log: not supported by cvs2svn $
94
95
96 // (c-file-style: "gnu")
97 // Local Variables:
98 // mode: php
99 // tab-width: 8
100 // c-basic-offset: 4
101 // c-hanging-comment-ender-p: nil
102 // indent-tabs-mode: nil
103 // End:   
104 ?>