5 * MS SQL extensions for the ADODB DB backend.
8 require_once 'lib/WikiDB/backend/ADODB.php';
10 class WikiDB_backend_ADODB_mssql
11 extends WikiDB_backend_ADODB
16 function WikiDB_backend_ADODB_mssql($dbparams) {
17 // Lowercase Assoc arrays
18 define('ADODB_ASSOC_CASE',0);
20 // Backend constructor
21 $this->WikiDB_backend_ADODB($dbparams);
23 // Empty strings in MSSQL? NULLS?
24 $this->_expressions['notempty'] = "NOT LIKE ''";
26 //$this->_expressions['iscontent'] = "content NOT LIKE ''";
28 $this->_prefix = isset($dbparams['prefix']) ? $dbparams['prefix'] : '';
35 // Do nothing here -- Leave that for the DB
36 // Cost Based Optimizer tuning vary from version to version
43 * We don't really need to lock exclusive, but I'll relax it when I fully
44 * understand phpWiki locking ;-)
47 function _lock_tables($tables, $write_lock = true) {
52 // Next line is default behaviour, so just skip it
53 // $dbh->Execute("SET TRANSACTION READ WRITE");
54 foreach ($tables as $table) {
55 if ($this->_prefix && !strstr($table, $this->_prefix)) {
56 $table = $this->_prefix . $table;
58 $dbh->Execute("LOCK TABLE $table IN EXCLUSIVE MODE");
61 // Just ensure read consistency
62 $dbh->Execute("SET TRANSACTION READ ONLY");
69 function _unlock_tables($tables) {
71 $dbh->Execute("COMMIT WORK");
76 function _sql_match_clause($word) {
77 $word = preg_replace('/(?=[%_\\\\])/', "\\", $word);
78 $word = $this->_dbh->qstr("%$word%");
79 return "LOWER(pagename) LIKE $word";
82 // Fulltext -- case sensitive :-\
83 function _fullsearch_sql_match_clause($word) {
84 $word = preg_replace('/(?=[%_\\\\])/', "\\", $word);
85 $wordq = $this->_dbh->qstr("%$word%");
86 return "LOWER(pagename) LIKE $wordq "
87 . "OR CHARINDEX(content, '$word') > 0";
93 function _serialize($data) {
96 assert(is_array($data));
97 return serialize(addslashes($data));
103 function _unserialize($data) {
104 return empty($data) ? array() : unserialize(stripslashes($data));
113 // c-hanging-comment-ender-p: nil
114 // indent-tabs-mode: nil