4 * MS SQL extensions for the ADODB DB backend.
7 require_once 'lib/WikiDB/backend/ADODB.php';
9 class WikiDB_backend_ADODB_mssql
10 extends WikiDB_backend_ADODB
15 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'] : '';
36 // Do nothing here -- Leave that for the DB
37 // Cost Based Optimizer tuning vary from version to version
44 * We don't really need to lock exclusive, but I'll relax it when I fully
45 * understand phpWiki locking ;-)
48 function _lock_tables($tables, $write_lock = true)
54 // Next line is default behaviour, so just skip it
55 // $dbh->Execute("SET TRANSACTION READ WRITE");
56 foreach ($tables as $table) {
57 if ($this->_prefix && !strstr($table, $this->_prefix)) {
58 $table = $this->_prefix . $table;
60 $dbh->Execute("LOCK TABLE $table IN EXCLUSIVE MODE");
63 // Just ensure read consistency
64 $dbh->Execute("SET TRANSACTION READ ONLY");
71 function _unlock_tables($tables)
74 $dbh->Execute("COMMIT WORK");
79 function _sql_match_clause($word)
81 $word = preg_replace('/(?=[%_\\\\])/', "\\", $word);
82 $word = $this->_dbh->qstr("%$word%");
83 return "LOWER(pagename) LIKE $word";
86 // Fulltext -- case sensitive :-\
87 function _fullsearch_sql_match_clause($word)
89 $word = preg_replace('/(?=[%_\\\\])/', "\\", $word);
90 $wordq = $this->_dbh->qstr("%$word%");
91 return "LOWER(pagename) LIKE $wordq "
92 . "OR CHARINDEX(content, '$word') > 0";
98 function _serialize($data)
102 assert(is_array($data));
103 return serialize(addslashes($data));
109 function _unserialize($data)
111 return empty($data) ? array() : unserialize(stripslashes($data));
120 // c-hanging-comment-ender-p: nil
121 // indent-tabs-mode: nil