Index: trunk/phase3/includes/db/DatabaseMssql.php |
— | — | @@ -1,968 +0,0 @@ |
2 | | -<?php |
3 | | -/** |
4 | | - * This script is the MSSQL Server database abstraction layer |
5 | | - * |
6 | | - * See maintenance/mssql/README for development notes and other specific information |
7 | | - * @ingroup Database |
8 | | - * @file |
9 | | - */ |
10 | | - |
11 | | -/** |
12 | | - * @ingroup Database |
13 | | - */ |
14 | | -class DatabaseMssql extends DatabaseBase { |
15 | | - |
16 | | - var $mAffectedRows; |
17 | | - var $mLastResult; |
18 | | - var $mLastError; |
19 | | - var $mLastErrorNo; |
20 | | - var $mDatabaseFile; |
21 | | - |
22 | | - /** |
23 | | - * Constructor |
24 | | - */ |
25 | | - function __construct($server = false, $user = false, $password = false, $dbName = false, |
26 | | - $failFunction = false, $flags = 0, $tablePrefix = 'get from global') { |
27 | | - |
28 | | - global $wgOut, $wgDBprefix, $wgCommandLineMode; |
29 | | - if (!isset($wgOut)) $wgOut = null; # Can't get a reference if it hasn't been set yet |
30 | | - $this->mOut =& $wgOut; |
31 | | - $this->mFailFunction = $failFunction; |
32 | | - $this->mFlags = $flags; |
33 | | - |
34 | | - if ( $this->mFlags & DBO_DEFAULT ) { |
35 | | - if ( $wgCommandLineMode ) { |
36 | | - $this->mFlags &= ~DBO_TRX; |
37 | | - } else { |
38 | | - $this->mFlags |= DBO_TRX; |
39 | | - } |
40 | | - } |
41 | | - |
42 | | - /** Get the default table prefix*/ |
43 | | - $this->mTablePrefix = $tablePrefix == 'get from global' ? $wgDBprefix : $tablePrefix; |
44 | | - |
45 | | - if ($server) $this->open($server, $user, $password, $dbName); |
46 | | - |
47 | | - } |
48 | | - |
49 | | - function getType() { |
50 | | - return 'mssql'; |
51 | | - } |
52 | | - |
53 | | - /** |
54 | | - * todo: check if these should be true like parent class |
55 | | - */ |
56 | | - function implicitGroupby() { return false; } |
57 | | - function implicitOrderby() { return false; } |
58 | | - |
59 | | - static function newFromParams($server, $user, $password, $dbName, $failFunction = false, $flags = 0) { |
60 | | - return new DatabaseMssql($server, $user, $password, $dbName, $failFunction, $flags); |
61 | | - } |
62 | | - |
63 | | - /** Open an MSSQL database and return a resource handle to it |
64 | | - * NOTE: only $dbName is used, the other parameters are irrelevant for MSSQL databases |
65 | | - */ |
66 | | - function open($server,$user,$password,$dbName) { |
67 | | - wfProfileIn(__METHOD__); |
68 | | - |
69 | | - # Test for missing mysql.so |
70 | | - # First try to load it |
71 | | - if (!@extension_loaded('mssql')) { |
72 | | - @dl('mssql.so'); |
73 | | - } |
74 | | - |
75 | | - # Fail now |
76 | | - # Otherwise we get a suppressed fatal error, which is very hard to track down |
77 | | - if (!function_exists( 'mssql_connect')) { |
78 | | - throw new DBConnectionError( $this, "MSSQL functions missing, have you compiled PHP with the --with-mssql option?\n" ); |
79 | | - } |
80 | | - |
81 | | - $this->close(); |
82 | | - $this->mServer = $server; |
83 | | - $this->mUser = $user; |
84 | | - $this->mPassword = $password; |
85 | | - $this->mDBname = $dbName; |
86 | | - |
87 | | - wfProfileIn("dbconnect-$server"); |
88 | | - |
89 | | - # Try to connect up to three times |
90 | | - # The kernel's default SYN retransmission period is far too slow for us, |
91 | | - # so we use a short timeout plus a manual retry. |
92 | | - $this->mConn = false; |
93 | | - $max = 3; |
94 | | - for ( $i = 0; $i < $max && !$this->mConn; $i++ ) { |
95 | | - if ( $i > 1 ) { |
96 | | - usleep( 1000 ); |
97 | | - } |
98 | | - if ($this->mFlags & DBO_PERSISTENT) { |
99 | | - @/**/$this->mConn = mssql_pconnect($server, $user, $password); |
100 | | - } else { |
101 | | - # Create a new connection... |
102 | | - @/**/$this->mConn = mssql_connect($server, $user, $password, true); |
103 | | - } |
104 | | - } |
105 | | - |
106 | | - wfProfileOut("dbconnect-$server"); |
107 | | - |
108 | | - if ($dbName != '') { |
109 | | - if ($this->mConn !== false) { |
110 | | - $success = @/**/mssql_select_db($dbName, $this->mConn); |
111 | | - if (!$success) { |
112 | | - $error = "Error selecting database $dbName on server {$this->mServer} " . |
113 | | - "from client host " . wfHostname() . "\n"; |
114 | | - wfLogDBError(" Error selecting database $dbName on server {$this->mServer} \n"); |
115 | | - wfDebug( $error ); |
116 | | - } |
117 | | - } else { |
118 | | - wfDebug("DB connection error\n"); |
119 | | - wfDebug("Server: $server, User: $user, Password: ".substr($password, 0, 3)."...\n"); |
120 | | - $success = false; |
121 | | - } |
122 | | - } else { |
123 | | - # Delay USE query |
124 | | - $success = (bool)$this->mConn; |
125 | | - } |
126 | | - |
127 | | - if (!$success) $this->reportConnectionError(); |
128 | | - $this->mOpened = $success; |
129 | | - wfProfileOut(__METHOD__); |
130 | | - return $success; |
131 | | - } |
132 | | - |
133 | | - /** |
134 | | - * Close an MSSQL database |
135 | | - */ |
136 | | - function close() { |
137 | | - $this->mOpened = false; |
138 | | - if ($this->mConn) { |
139 | | - if ($this->trxLevel()) $this->commit(); |
140 | | - return mssql_close($this->mConn); |
141 | | - } else return true; |
142 | | - } |
143 | | - |
144 | | - /** |
145 | | - * - MSSQL doesn't seem to do buffered results |
146 | | - * - the trasnaction syntax is modified here to avoid having to replicate |
147 | | - * Database::query which uses BEGIN, COMMIT, ROLLBACK |
148 | | - */ |
149 | | - function doQuery($sql) { |
150 | | - if ($sql == 'BEGIN' || $sql == 'COMMIT' || $sql == 'ROLLBACK') return true; # $sql .= ' TRANSACTION'; |
151 | | - $sql = preg_replace('|[^\x07-\x7e]|','?',$sql); # TODO: need to fix unicode - just removing it here while testing |
152 | | - $ret = mssql_query($sql, $this->mConn); |
153 | | - if ($ret === false) { |
154 | | - $err = mssql_get_last_message(); |
155 | | - if ($err) $this->mlastError = $err; |
156 | | - $row = mssql_fetch_row(mssql_query('select @@ERROR')); |
157 | | - if ($row[0]) $this->mlastErrorNo = $row[0]; |
158 | | - } else $this->mlastErrorNo = false; |
159 | | - return $ret; |
160 | | - } |
161 | | - |
162 | | - /** |
163 | | - * Free a result object |
164 | | - */ |
165 | | - function freeResult( $res ) { |
166 | | - if ( $res instanceof ResultWrapper ) { |
167 | | - $res = $res->result; |
168 | | - } |
169 | | - if ( !@/**/mssql_free_result( $res ) ) { |
170 | | - throw new DBUnexpectedError( $this, "Unable to free MSSQL result" ); |
171 | | - } |
172 | | - } |
173 | | - |
174 | | - /** |
175 | | - * Fetch the next row from the given result object, in object form. |
176 | | - * Fields can be retrieved with $row->fieldname, with fields acting like |
177 | | - * member variables. |
178 | | - * |
179 | | - * @param $res SQL result object as returned from Database::query(), etc. |
180 | | - * @return MySQL row object |
181 | | - * @throws DBUnexpectedError Thrown if the database returns an error |
182 | | - */ |
183 | | - function fetchObject( $res ) { |
184 | | - if ( $res instanceof ResultWrapper ) { |
185 | | - $res = $res->result; |
186 | | - } |
187 | | - @/**/$row = mssql_fetch_object( $res ); |
188 | | - if ( $this->lastErrno() ) { |
189 | | - throw new DBUnexpectedError( $this, 'Error in fetchObject(): ' . htmlspecialchars( $this->lastError() ) ); |
190 | | - } |
191 | | - return $row; |
192 | | - } |
193 | | - |
194 | | - /** |
195 | | - * Fetch the next row from the given result object, in associative array |
196 | | - * form. Fields are retrieved with $row['fieldname']. |
197 | | - * |
198 | | - * @param $res SQL result object as returned from Database::query(), etc. |
199 | | - * @return MySQL row object |
200 | | - * @throws DBUnexpectedError Thrown if the database returns an error |
201 | | - */ |
202 | | - function fetchRow( $res ) { |
203 | | - if ( $res instanceof ResultWrapper ) { |
204 | | - $res = $res->result; |
205 | | - } |
206 | | - @/**/$row = mssql_fetch_array( $res ); |
207 | | - if ( $this->lastErrno() ) { |
208 | | - throw new DBUnexpectedError( $this, 'Error in fetchRow(): ' . htmlspecialchars( $this->lastError() ) ); |
209 | | - } |
210 | | - return $row; |
211 | | - } |
212 | | - |
213 | | - /** |
214 | | - * Get the number of rows in a result object |
215 | | - */ |
216 | | - function numRows( $res ) { |
217 | | - if ( $res instanceof ResultWrapper ) { |
218 | | - $res = $res->result; |
219 | | - } |
220 | | - @/**/$n = mssql_num_rows( $res ); |
221 | | - if ( $this->lastErrno() ) { |
222 | | - throw new DBUnexpectedError( $this, 'Error in numRows(): ' . htmlspecialchars( $this->lastError() ) ); |
223 | | - } |
224 | | - return $n; |
225 | | - } |
226 | | - |
227 | | - /** |
228 | | - * Get the number of fields in a result object |
229 | | - * See documentation for mysql_num_fields() |
230 | | - * @param $res SQL result object as returned from Database::query(), etc. |
231 | | - */ |
232 | | - function numFields( $res ) { |
233 | | - if ( $res instanceof ResultWrapper ) { |
234 | | - $res = $res->result; |
235 | | - } |
236 | | - return mssql_num_fields( $res ); |
237 | | - } |
238 | | - |
239 | | - /** |
240 | | - * Get a field name in a result object |
241 | | - * See documentation for mysql_field_name(): |
242 | | - * http://www.php.net/mysql_field_name |
243 | | - * @param $res SQL result object as returned from Database::query(), etc. |
244 | | - * @param $n Int |
245 | | - */ |
246 | | - function fieldName( $res, $n ) { |
247 | | - if ( $res instanceof ResultWrapper ) { |
248 | | - $res = $res->result; |
249 | | - } |
250 | | - return mssql_field_name( $res, $n ); |
251 | | - } |
252 | | - |
253 | | - /** |
254 | | - * Get the inserted value of an auto-increment row |
255 | | - * |
256 | | - * The value inserted should be fetched from nextSequenceValue() |
257 | | - * |
258 | | - * Example: |
259 | | - * $id = $dbw->nextSequenceValue('page_page_id_seq'); |
260 | | - * $dbw->insert('page',array('page_id' => $id)); |
261 | | - * $id = $dbw->insertId(); |
262 | | - */ |
263 | | - function insertId() { |
264 | | - $row = mssql_fetch_row(mssql_query('select @@IDENTITY')); |
265 | | - return $row[0]; |
266 | | - } |
267 | | - |
268 | | - /** |
269 | | - * Change the position of the cursor in a result object |
270 | | - * See mysql_data_seek() |
271 | | - * @param $res SQL result object as returned from Database::query(), etc. |
272 | | - * @param $row Database row |
273 | | - */ |
274 | | - function dataSeek( $res, $row ) { |
275 | | - if ( $res instanceof ResultWrapper ) { |
276 | | - $res = $res->result; |
277 | | - } |
278 | | - return mssql_data_seek( $res, $row ); |
279 | | - } |
280 | | - |
281 | | - /** |
282 | | - * Get the last error number |
283 | | - */ |
284 | | - function lastErrno() { |
285 | | - return $this->mlastErrorNo; |
286 | | - } |
287 | | - |
288 | | - /** |
289 | | - * Get a description of the last error |
290 | | - */ |
291 | | - function lastError() { |
292 | | - return $this->mlastError; |
293 | | - } |
294 | | - |
295 | | - /** |
296 | | - * Get the number of rows affected by the last write query |
297 | | - */ |
298 | | - function affectedRows() { |
299 | | - return mssql_rows_affected( $this->mConn ); |
300 | | - } |
301 | | - |
302 | | - /** |
303 | | - * Simple UPDATE wrapper |
304 | | - * Usually aborts on failure |
305 | | - * If errors are explicitly ignored, returns success |
306 | | - * |
307 | | - * This function exists for historical reasons, Database::update() has a more standard |
308 | | - * calling convention and feature set |
309 | | - */ |
310 | | - function set( $table, $var, $value, $cond, $fname = 'Database::set' ) |
311 | | - { |
312 | | - if ($value == "NULL") $value = "''"; # see comments in makeListWithoutNulls() |
313 | | - $table = $this->tableName( $table ); |
314 | | - $sql = "UPDATE $table SET $var = '" . |
315 | | - $this->strencode( $value ) . "' WHERE ($cond)"; |
316 | | - return (bool)$this->query( $sql, $fname ); |
317 | | - } |
318 | | - |
319 | | - /** |
320 | | - * Simple SELECT wrapper, returns a single field, input must be encoded |
321 | | - * Usually aborts on failure |
322 | | - * If errors are explicitly ignored, returns FALSE on failure |
323 | | - */ |
324 | | - function selectField( $table, $var, $cond='', $fname = 'Database::selectField', $options = array() ) { |
325 | | - if ( !is_array( $options ) ) { |
326 | | - $options = array( $options ); |
327 | | - } |
328 | | - $options['LIMIT'] = 1; |
329 | | - |
330 | | - $res = $this->select( $table, $var, $cond, $fname, $options ); |
331 | | - if ( $res === false || !$this->numRows( $res ) ) { |
332 | | - return false; |
333 | | - } |
334 | | - $row = $this->fetchRow( $res ); |
335 | | - if ( $row !== false ) { |
336 | | - $this->freeResult( $res ); |
337 | | - return $row[0]; |
338 | | - } else { |
339 | | - return false; |
340 | | - } |
341 | | - } |
342 | | - |
343 | | - /** |
344 | | - * Returns an optional USE INDEX clause to go after the table, and a |
345 | | - * string to go at the end of the query |
346 | | - * |
347 | | - * @private |
348 | | - * |
349 | | - * @param $options Array: an associative array of options to be turned into |
350 | | - * an SQL query, valid keys are listed in the function. |
351 | | - * @return array |
352 | | - */ |
353 | | - function makeSelectOptions( $options ) { |
354 | | - $preLimitTail = $postLimitTail = ''; |
355 | | - $startOpts = ''; |
356 | | - |
357 | | - $noKeyOptions = array(); |
358 | | - foreach ( $options as $key => $option ) { |
359 | | - if ( is_numeric( $key ) ) { |
360 | | - $noKeyOptions[$option] = true; |
361 | | - } |
362 | | - } |
363 | | - |
364 | | - if ( isset( $options['GROUP BY'] ) ) $preLimitTail .= " GROUP BY {$options['GROUP BY']}"; |
365 | | - if ( isset( $options['HAVING'] ) ) $preLimitTail .= " HAVING {$options['HAVING']}"; |
366 | | - if ( isset( $options['ORDER BY'] ) ) $preLimitTail .= " ORDER BY {$options['ORDER BY']}"; |
367 | | - |
368 | | - //if (isset($options['LIMIT'])) { |
369 | | - // $tailOpts .= $this->limitResult('', $options['LIMIT'], |
370 | | - // isset($options['OFFSET']) ? $options['OFFSET'] |
371 | | - // : false); |
372 | | - //} |
373 | | - |
374 | | - if ( isset( $noKeyOptions['FOR UPDATE'] ) ) $postLimitTail .= ' FOR UPDATE'; |
375 | | - if ( isset( $noKeyOptions['LOCK IN SHARE MODE'] ) ) $postLimitTail .= ' LOCK IN SHARE MODE'; |
376 | | - if ( isset( $noKeyOptions['DISTINCT'] ) || isset( $noKeyOptions['DISTINCTROW'] ) ) $startOpts .= 'DISTINCT'; |
377 | | - |
378 | | - # Various MySQL extensions |
379 | | - if ( isset( $noKeyOptions['STRAIGHT_JOIN'] ) ) $startOpts .= ' /*! STRAIGHT_JOIN */'; |
380 | | - if ( isset( $noKeyOptions['HIGH_PRIORITY'] ) ) $startOpts .= ' HIGH_PRIORITY'; |
381 | | - if ( isset( $noKeyOptions['SQL_BIG_RESULT'] ) ) $startOpts .= ' SQL_BIG_RESULT'; |
382 | | - if ( isset( $noKeyOptions['SQL_BUFFER_RESULT'] ) ) $startOpts .= ' SQL_BUFFER_RESULT'; |
383 | | - if ( isset( $noKeyOptions['SQL_SMALL_RESULT'] ) ) $startOpts .= ' SQL_SMALL_RESULT'; |
384 | | - if ( isset( $noKeyOptions['SQL_CALC_FOUND_ROWS'] ) ) $startOpts .= ' SQL_CALC_FOUND_ROWS'; |
385 | | - if ( isset( $noKeyOptions['SQL_CACHE'] ) ) $startOpts .= ' SQL_CACHE'; |
386 | | - if ( isset( $noKeyOptions['SQL_NO_CACHE'] ) ) $startOpts .= ' SQL_NO_CACHE'; |
387 | | - |
388 | | - if ( isset( $options['USE INDEX'] ) && ! is_array( $options['USE INDEX'] ) ) { |
389 | | - $useIndex = $this->useIndexClause( $options['USE INDEX'] ); |
390 | | - } else { |
391 | | - $useIndex = ''; |
392 | | - } |
393 | | - |
394 | | - return array( $startOpts, $useIndex, $preLimitTail, $postLimitTail ); |
395 | | - } |
396 | | - |
397 | | - /** |
398 | | - * SELECT wrapper |
399 | | - * |
400 | | - * @param $table Mixed: Array or string, table name(s) (prefix auto-added) |
401 | | - * @param $vars Mixed: Array or string, field name(s) to be retrieved |
402 | | - * @param $conds Mixed: Array or string, condition(s) for WHERE |
403 | | - * @param $fname String: Calling function name (use __METHOD__) for logs/profiling |
404 | | - * @param $options Array: Associative array of options (e.g. array('GROUP BY' => 'page_title')), |
405 | | - * see Database::makeSelectOptions code for list of supported stuff |
406 | | - * @return mixed Database result resource (feed to Database::fetchObject or whatever), or false on failure |
407 | | - */ |
408 | | - function select( $table, $vars, $conds='', $fname = 'Database::select', $options = array() ) |
409 | | - { |
410 | | - if( is_array( $vars ) ) { |
411 | | - $vars = implode( ',', $vars ); |
412 | | - } |
413 | | - if( !is_array( $options ) ) { |
414 | | - $options = array( $options ); |
415 | | - } |
416 | | - if( is_array( $table ) ) { |
417 | | - if ( isset( $options['USE INDEX'] ) && is_array( $options['USE INDEX'] ) ) |
418 | | - $from = ' FROM ' . $this->tableNamesWithUseIndex( $table, $options['USE INDEX'] ); |
419 | | - else |
420 | | - $from = ' FROM ' . implode( ',', array_map( array( &$this, 'tableName' ), $table ) ); |
421 | | - } elseif ($table!='') { |
422 | | - if ($table{0}==' ') { |
423 | | - $from = ' FROM ' . $table; |
424 | | - } else { |
425 | | - $from = ' FROM ' . $this->tableName( $table ); |
426 | | - } |
427 | | - } else { |
428 | | - $from = ''; |
429 | | - } |
430 | | - |
431 | | - list( $startOpts, $useIndex, $preLimitTail, $postLimitTail ) = $this->makeSelectOptions( $options ); |
432 | | - |
433 | | - if( !empty( $conds ) ) { |
434 | | - if ( is_array( $conds ) ) { |
435 | | - $conds = $this->makeList( $conds, LIST_AND ); |
436 | | - } |
437 | | - $sql = "SELECT $startOpts $vars $from $useIndex WHERE $conds $preLimitTail"; |
438 | | - } else { |
439 | | - $sql = "SELECT $startOpts $vars $from $useIndex $preLimitTail"; |
440 | | - } |
441 | | - |
442 | | - if (isset($options['LIMIT'])) |
443 | | - $sql = $this->limitResult($sql, $options['LIMIT'], |
444 | | - isset($options['OFFSET']) ? $options['OFFSET'] : false); |
445 | | - $sql = "$sql $postLimitTail"; |
446 | | - |
447 | | - if (isset($options['EXPLAIN'])) { |
448 | | - $sql = 'EXPLAIN ' . $sql; |
449 | | - } |
450 | | - return $this->query( $sql, $fname ); |
451 | | - } |
452 | | - |
453 | | - /** |
454 | | - * Determines whether a field exists in a table |
455 | | - * Usually aborts on failure |
456 | | - * If errors are explicitly ignored, returns NULL on failure |
457 | | - */ |
458 | | - function fieldExists( $table, $field, $fname = 'Database::fieldExists' ) { |
459 | | - $table = $this->tableName( $table ); |
460 | | - $sql = "SELECT TOP 1 * FROM $table"; |
461 | | - $res = $this->query( $sql, 'Database::fieldExists' ); |
462 | | - |
463 | | - $found = false; |
464 | | - while ( $row = $this->fetchArray( $res ) ) { |
465 | | - if ( isset($row[$field]) ) { |
466 | | - $found = true; |
467 | | - break; |
468 | | - } |
469 | | - } |
470 | | - |
471 | | - $this->freeResult( $res ); |
472 | | - return $found; |
473 | | - } |
474 | | - |
475 | | - /** |
476 | | - * Get information about an index into an object |
477 | | - * Returns false if the index does not exist |
478 | | - */ |
479 | | - function indexInfo( $table, $index, $fname = 'Database::indexInfo' ) { |
480 | | - |
481 | | - throw new DBUnexpectedError( $this, 'Database::indexInfo called which is not supported yet' ); |
482 | | - return null; |
483 | | - |
484 | | - $table = $this->tableName( $table ); |
485 | | - $sql = 'SHOW INDEX FROM '.$table; |
486 | | - $res = $this->query( $sql, $fname ); |
487 | | - if ( !$res ) { |
488 | | - return null; |
489 | | - } |
490 | | - |
491 | | - $result = array(); |
492 | | - while ( $row = $this->fetchObject( $res ) ) { |
493 | | - if ( $row->Key_name == $index ) { |
494 | | - $result[] = $row; |
495 | | - } |
496 | | - } |
497 | | - $this->freeResult($res); |
498 | | - |
499 | | - return empty($result) ? false : $result; |
500 | | - } |
501 | | - |
502 | | - /** |
503 | | - * Query whether a given table exists |
504 | | - */ |
505 | | - function tableExists( $table ) { |
506 | | - $table = $this->tableName( $table ); |
507 | | - $res = $this->query( "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = '$table'" ); |
508 | | - $exist = ($res->numRows() > 0); |
509 | | - $this->freeResult($res); |
510 | | - return $exist; |
511 | | - } |
512 | | - |
513 | | - /** |
514 | | - * mysql_fetch_field() wrapper |
515 | | - * Returns false if the field doesn't exist |
516 | | - * |
517 | | - * @param $table |
518 | | - * @param $field |
519 | | - */ |
520 | | - function fieldInfo( $table, $field ) { |
521 | | - $table = $this->tableName( $table ); |
522 | | - $res = $this->query( "SELECT TOP 1 * FROM $table" ); |
523 | | - $n = mssql_num_fields( $res->result ); |
524 | | - for( $i = 0; $i < $n; $i++ ) { |
525 | | - $meta = mssql_fetch_field( $res->result, $i ); |
526 | | - if( $field == $meta->name ) { |
527 | | - return new MSSQLField($meta); |
528 | | - } |
529 | | - } |
530 | | - return false; |
531 | | - } |
532 | | - |
533 | | - /** |
534 | | - * mysql_field_type() wrapper |
535 | | - */ |
536 | | - function fieldType( $res, $index ) { |
537 | | - if ( $res instanceof ResultWrapper ) { |
538 | | - $res = $res->result; |
539 | | - } |
540 | | - return mssql_field_type( $res, $index ); |
541 | | - } |
542 | | - |
543 | | - /** |
544 | | - * INSERT wrapper, inserts an array into a table |
545 | | - * |
546 | | - * $a may be a single associative array, or an array of these with numeric keys, for |
547 | | - * multi-row insert. |
548 | | - * |
549 | | - * Usually aborts on failure |
550 | | - * If errors are explicitly ignored, returns success |
551 | | - * |
552 | | - * Same as parent class implementation except that it removes primary key from column lists |
553 | | - * because MSSQL doesn't support writing nulls to IDENTITY (AUTO_INCREMENT) columns |
554 | | - */ |
555 | | - function insert( $table, $a, $fname = 'Database::insert', $options = array() ) { |
556 | | - # No rows to insert, easy just return now |
557 | | - if ( !count( $a ) ) { |
558 | | - return true; |
559 | | - } |
560 | | - $table = $this->tableName( $table ); |
561 | | - if ( !is_array( $options ) ) { |
562 | | - $options = array( $options ); |
563 | | - } |
564 | | - |
565 | | - # todo: need to record primary keys at table create time, and remove NULL assignments to them |
566 | | - if ( isset( $a[0] ) && is_array( $a[0] ) ) { |
567 | | - $multi = true; |
568 | | - $keys = array_keys( $a[0] ); |
569 | | -# if (ereg('_id$',$keys[0])) { |
570 | | - foreach ($a as $i) { |
571 | | - if (is_null($i[$keys[0]])) unset($i[$keys[0]]); # remove primary-key column from multiple insert lists if empty value |
572 | | - } |
573 | | -# } |
574 | | - $keys = array_keys( $a[0] ); |
575 | | - } else { |
576 | | - $multi = false; |
577 | | - $keys = array_keys( $a ); |
578 | | -# if (ereg('_id$',$keys[0]) && empty($a[$keys[0]])) unset($a[$keys[0]]); # remove primary-key column from insert list if empty value |
579 | | - if (is_null($a[$keys[0]])) unset($a[$keys[0]]); # remove primary-key column from insert list if empty value |
580 | | - $keys = array_keys( $a ); |
581 | | - } |
582 | | - |
583 | | - # handle IGNORE option |
584 | | - # example: |
585 | | - # MySQL: INSERT IGNORE INTO user_groups (ug_user,ug_group) VALUES ('1','sysop') |
586 | | - # MSSQL: IF NOT EXISTS (SELECT * FROM user_groups WHERE ug_user = '1') INSERT INTO user_groups (ug_user,ug_group) VALUES ('1','sysop') |
587 | | - $ignore = in_array('IGNORE',$options); |
588 | | - |
589 | | - # remove IGNORE from options list |
590 | | - if ($ignore) { |
591 | | - $oldoptions = $options; |
592 | | - $options = array(); |
593 | | - foreach ($oldoptions as $o) if ($o != 'IGNORE') $options[] = $o; |
594 | | - } |
595 | | - |
596 | | - $keylist = implode(',', $keys); |
597 | | - $sql = 'INSERT '.implode(' ', $options)." INTO $table (".implode(',', $keys).') VALUES '; |
598 | | - if ($multi) { |
599 | | - if ($ignore) { |
600 | | - # If multiple and ignore, then do each row as a separate conditional insert |
601 | | - foreach ($a as $row) { |
602 | | - $prival = $row[$keys[0]]; |
603 | | - $sql = "IF NOT EXISTS (SELECT * FROM $table WHERE $keys[0] = '$prival') $sql"; |
604 | | - if (!$this->query("$sql (".$this->makeListWithoutNulls($row).')', $fname)) return false; |
605 | | - } |
606 | | - return true; |
607 | | - } else { |
608 | | - $first = true; |
609 | | - foreach ($a as $row) { |
610 | | - if ($first) $first = false; else $sql .= ','; |
611 | | - $sql .= '('.$this->makeListWithoutNulls($row).')'; |
612 | | - } |
613 | | - } |
614 | | - } else { |
615 | | - if ($ignore) { |
616 | | - $prival = $a[$keys[0]]; |
617 | | - $sql = "IF NOT EXISTS (SELECT * FROM $table WHERE $keys[0] = '$prival') $sql"; |
618 | | - } |
619 | | - $sql .= '('.$this->makeListWithoutNulls($a).')'; |
620 | | - } |
621 | | - return (bool)$this->query( $sql, $fname ); |
622 | | - } |
623 | | - |
624 | | - /** |
625 | | - * MSSQL doesn't allow implicit casting of NULL's into non-null values for NOT NULL columns |
626 | | - * for now I've just converted the NULL's in the lists for updates and inserts into empty strings |
627 | | - * which get implicitly casted to 0 for numeric columns |
628 | | - * NOTE: the set() method above converts NULL to empty string as well but not via this method |
629 | | - */ |
630 | | - function makeListWithoutNulls($a, $mode = LIST_COMMA) { |
631 | | - return str_replace("NULL","''",$this->makeList($a,$mode)); |
632 | | - } |
633 | | - |
634 | | - /** |
635 | | - * UPDATE wrapper, takes a condition array and a SET array |
636 | | - * |
637 | | - * @param $table String: The table to UPDATE |
638 | | - * @param $values Array: An array of values to SET |
639 | | - * @param $conds Array: An array of conditions (WHERE). Use '*' to update all rows. |
640 | | - * @param $fname String: The Class::Function calling this function |
641 | | - * (for the log) |
642 | | - * @param $options Array: An array of UPDATE options, can be one or |
643 | | - * more of IGNORE, LOW_PRIORITY |
644 | | - * @return bool |
645 | | - */ |
646 | | - function update( $table, $values, $conds, $fname = 'Database::update', $options = array() ) { |
647 | | - $table = $this->tableName( $table ); |
648 | | - $opts = $this->makeUpdateOptions( $options ); |
649 | | - $sql = "UPDATE $opts $table SET " . $this->makeListWithoutNulls( $values, LIST_SET ); |
650 | | - if ( $conds != '*' ) { |
651 | | - $sql .= " WHERE " . $this->makeList( $conds, LIST_AND ); |
652 | | - } |
653 | | - return $this->query( $sql, $fname ); |
654 | | - } |
655 | | - |
656 | | - /** |
657 | | - * Make UPDATE options for the Database::update function |
658 | | - * |
659 | | - * @private |
660 | | - * @param $options Array: The options passed to Database::update |
661 | | - * @return string |
662 | | - */ |
663 | | - function makeUpdateOptions( $options ) { |
664 | | - if( !is_array( $options ) ) { |
665 | | - $options = array( $options ); |
666 | | - } |
667 | | - $opts = array(); |
668 | | - if ( in_array( 'LOW_PRIORITY', $options ) ) |
669 | | - $opts[] = $this->lowPriorityOption(); |
670 | | - if ( in_array( 'IGNORE', $options ) ) |
671 | | - $opts[] = 'IGNORE'; |
672 | | - return implode(' ', $opts); |
673 | | - } |
674 | | - |
675 | | - /** |
676 | | - * Change the current database |
677 | | - */ |
678 | | - function selectDB( $db ) { |
679 | | - $this->mDBname = $db; |
680 | | - return mssql_select_db( $db, $this->mConn ); |
681 | | - } |
682 | | - |
683 | | - /** |
684 | | - * MSSQL has a problem with the backtick quoting, so all this does is ensure the prefix is added exactly once |
685 | | - */ |
686 | | - function tableName($name) { |
687 | | - return strpos($name, $this->mTablePrefix) === 0 ? $name : "{$this->mTablePrefix}$name"; |
688 | | - } |
689 | | - |
690 | | - /** |
691 | | - * MSSQL doubles quotes instead of escaping them |
692 | | - * @param $s String to be slashed. |
693 | | - * @return string slashed string. |
694 | | - */ |
695 | | - function strencode($s) { |
696 | | - return str_replace("'","''",$s); |
697 | | - } |
698 | | - |
699 | | - /** |
700 | | - * REPLACE query wrapper |
701 | | - * PostgreSQL simulates this with a DELETE followed by INSERT |
702 | | - * $row is the row to insert, an associative array |
703 | | - * $uniqueIndexes is an array of indexes. Each element may be either a |
704 | | - * field name or an array of field names |
705 | | - * |
706 | | - * It may be more efficient to leave off unique indexes which are unlikely to collide. |
707 | | - * However if you do this, you run the risk of encountering errors which wouldn't have |
708 | | - * occurred in MySQL |
709 | | - * |
710 | | - * @todo migrate comment to phodocumentor format |
711 | | - */ |
712 | | - function replace( $table, $uniqueIndexes, $rows, $fname = 'Database::replace' ) { |
713 | | - $table = $this->tableName( $table ); |
714 | | - |
715 | | - # Single row case |
716 | | - if ( !is_array( reset( $rows ) ) ) { |
717 | | - $rows = array( $rows ); |
718 | | - } |
719 | | - |
720 | | - $sql = "REPLACE INTO $table (" . implode( ',', array_keys( $rows[0] ) ) .') VALUES '; |
721 | | - $first = true; |
722 | | - foreach ( $rows as $row ) { |
723 | | - if ( $first ) { |
724 | | - $first = false; |
725 | | - } else { |
726 | | - $sql .= ','; |
727 | | - } |
728 | | - $sql .= '(' . $this->makeList( $row ) . ')'; |
729 | | - } |
730 | | - return $this->query( $sql, $fname ); |
731 | | - } |
732 | | - |
733 | | - /** |
734 | | - * DELETE where the condition is a join |
735 | | - * MySQL does this with a multi-table DELETE syntax, PostgreSQL does it with sub-selects |
736 | | - * |
737 | | - * For safety, an empty $conds will not delete everything. If you want to delete all rows where the |
738 | | - * join condition matches, set $conds='*' |
739 | | - * |
740 | | - * DO NOT put the join condition in $conds |
741 | | - * |
742 | | - * @param $delTable String: The table to delete from. |
743 | | - * @param $joinTable String: The other table. |
744 | | - * @param $delVar String: The variable to join on, in the first table. |
745 | | - * @param $joinVar String: The variable to join on, in the second table. |
746 | | - * @param $conds Array: Condition array of field names mapped to variables, ANDed together in the WHERE clause |
747 | | - * @param $fname String: Calling function name |
748 | | - */ |
749 | | - function deleteJoin( $delTable, $joinTable, $delVar, $joinVar, $conds, $fname = 'Database::deleteJoin' ) { |
750 | | - if ( !$conds ) { |
751 | | - throw new DBUnexpectedError( $this, 'Database::deleteJoin() called with empty $conds' ); |
752 | | - } |
753 | | - |
754 | | - $delTable = $this->tableName( $delTable ); |
755 | | - $joinTable = $this->tableName( $joinTable ); |
756 | | - $sql = "DELETE $delTable FROM $delTable, $joinTable WHERE $delVar=$joinVar "; |
757 | | - if ( $conds != '*' ) { |
758 | | - $sql .= ' AND ' . $this->makeList( $conds, LIST_AND ); |
759 | | - } |
760 | | - |
761 | | - return $this->query( $sql, $fname ); |
762 | | - } |
763 | | - |
764 | | - /** |
765 | | - * Returns the size of a text field, or -1 for "unlimited" |
766 | | - */ |
767 | | - function textFieldSize( $table, $field ) { |
768 | | - $table = $this->tableName( $table ); |
769 | | - $sql = "SELECT TOP 1 * FROM $table;"; |
770 | | - $res = $this->query( $sql, 'Database::textFieldSize' ); |
771 | | - $row = $this->fetchObject( $res ); |
772 | | - $this->freeResult( $res ); |
773 | | - |
774 | | - $m = array(); |
775 | | - if ( preg_match( '/\((.*)\)/', $row->Type, $m ) ) { |
776 | | - $size = $m[1]; |
777 | | - } else { |
778 | | - $size = -1; |
779 | | - } |
780 | | - return $size; |
781 | | - } |
782 | | - |
783 | | - /** |
784 | | - * @return string Returns the text of the low priority option if it is supported, or a blank string otherwise |
785 | | - */ |
786 | | - function lowPriorityOption() { |
787 | | - return 'LOW_PRIORITY'; |
788 | | - } |
789 | | - |
790 | | - /** |
791 | | - * INSERT SELECT wrapper |
792 | | - * $varMap must be an associative array of the form array( 'dest1' => 'source1', ...) |
793 | | - * Source items may be literals rather than field names, but strings should be quoted with Database::addQuotes() |
794 | | - * $conds may be "*" to copy the whole table |
795 | | - * srcTable may be an array of tables. |
796 | | - */ |
797 | | - function insertSelect( $destTable, $srcTable, $varMap, $conds, $fname = 'Database::insertSelect', |
798 | | - $insertOptions = array(), $selectOptions = array() ) |
799 | | - { |
800 | | - $destTable = $this->tableName( $destTable ); |
801 | | - if ( is_array( $insertOptions ) ) { |
802 | | - $insertOptions = implode( ' ', $insertOptions ); |
803 | | - } |
804 | | - if( !is_array( $selectOptions ) ) { |
805 | | - $selectOptions = array( $selectOptions ); |
806 | | - } |
807 | | - list( $startOpts, $useIndex, $tailOpts ) = $this->makeSelectOptions( $selectOptions ); |
808 | | - if( is_array( $srcTable ) ) { |
809 | | - $srcTable = implode( ',', array_map( array( &$this, 'tableName' ), $srcTable ) ); |
810 | | - } else { |
811 | | - $srcTable = $this->tableName( $srcTable ); |
812 | | - } |
813 | | - $sql = "INSERT $insertOptions INTO $destTable (" . implode( ',', array_keys( $varMap ) ) . ')' . |
814 | | - " SELECT $startOpts " . implode( ',', $varMap ) . |
815 | | - " FROM $srcTable $useIndex "; |
816 | | - if ( $conds != '*' ) { |
817 | | - $sql .= ' WHERE ' . $this->makeList( $conds, LIST_AND ); |
818 | | - } |
819 | | - $sql .= " $tailOpts"; |
820 | | - return $this->query( $sql, $fname ); |
821 | | - } |
822 | | - |
823 | | - /** |
824 | | - * Construct a LIMIT query with optional offset |
825 | | - * This is used for query pages |
826 | | - * $sql string SQL query we will append the limit to |
827 | | - * $limit integer the SQL limit |
828 | | - * $offset integer the SQL offset (default false) |
829 | | - */ |
830 | | - function limitResult($sql, $limit, $offset=false) { |
831 | | - if( !is_numeric($limit) ) { |
832 | | - throw new DBUnexpectedError( $this, "Invalid non-numeric limit passed to limitResult()\n" ); |
833 | | - } |
834 | | - if ($offset) { |
835 | | - throw new DBUnexpectedError( $this, 'Database::limitResult called with non-zero offset which is not supported yet' ); |
836 | | - } else { |
837 | | - $sql = preg_replace("/^SELECT/i", "SELECT TOP $limit", $sql); |
838 | | - } |
839 | | - return $sql; |
840 | | - } |
841 | | - |
842 | | - /** |
843 | | - * Should determine if the last failure was due to a deadlock |
844 | | - * @return bool |
845 | | - */ |
846 | | - function wasDeadlock() { |
847 | | - return $this->lastErrno() == 1205; |
848 | | - } |
849 | | - |
850 | | - /** |
851 | | - * Return MW-style timestamp used for MySQL schema |
852 | | - */ |
853 | | - function timestamp( $ts=0 ) { |
854 | | - return wfTimestamp(TS_MW,$ts); |
855 | | - } |
856 | | - |
857 | | - /** |
858 | | - * Local database timestamp format or null |
859 | | - */ |
860 | | - function timestampOrNull( $ts = null ) { |
861 | | - if( is_null( $ts ) ) { |
862 | | - return null; |
863 | | - } else { |
864 | | - return $this->timestamp( $ts ); |
865 | | - } |
866 | | - } |
867 | | - |
868 | | - /** |
869 | | - * @return string wikitext of a link to the server software's web site |
870 | | - */ |
871 | | - function getSoftwareLink() { |
872 | | - return "[http://www.microsoft.com/sql/default.mspx Microsoft SQL Server 2005 Home]"; |
873 | | - } |
874 | | - |
875 | | - /** |
876 | | - * @return string Version information from the database |
877 | | - */ |
878 | | - function getServerVersion() { |
879 | | - $row = mssql_fetch_row(mssql_query('select @@VERSION')); |
880 | | - return preg_match("/^(.+[0-9]+\\.[0-9]+\\.[0-9]+) /",$row[0],$m) ? $m[1] : $row[0]; |
881 | | - } |
882 | | - |
883 | | - function limitResultForUpdate($sql, $num) { |
884 | | - return $sql; |
885 | | - } |
886 | | - |
887 | | - /** |
888 | | - * How lagged is this slave? |
889 | | - */ |
890 | | - public function getLag() { |
891 | | - return 0; |
892 | | - } |
893 | | - |
894 | | - /** |
895 | | - * Called by the installer script |
896 | | - * - this is the same way as DatabasePostgresql.php, MySQL reads in tables.sql and interwiki.sql using dbsource (which calls db->sourceFile) |
897 | | - */ |
898 | | - public function setup_database() { |
899 | | - global $IP,$wgDBTableOptions; |
900 | | - $wgDBTableOptions = ''; |
901 | | - $mysql_tmpl = "$IP/maintenance/tables.sql"; |
902 | | - $mysql_iw = "$IP/maintenance/interwiki.sql"; |
903 | | - $mssql_tmpl = "$IP/maintenance/mssql/tables.sql"; |
904 | | - |
905 | | - # Make an MSSQL template file if it doesn't exist (based on the same one MySQL uses to create a new wiki db) |
906 | | - if (!file_exists($mssql_tmpl)) { # todo: make this conditional again |
907 | | - $sql = file_get_contents($mysql_tmpl); |
908 | | - $sql = preg_replace('/^\s*--.*?$/m','',$sql); # strip comments |
909 | | - $sql = preg_replace('/^\s*(UNIQUE )?(INDEX|KEY|FULLTEXT).+?$/m', '', $sql); # These indexes should be created with a CREATE INDEX query |
910 | | - $sql = preg_replace('/(\sKEY) [^\(]+\(/is', '$1 (', $sql); # "KEY foo (foo)" should just be "KEY (foo)" |
911 | | - $sql = preg_replace('/(varchar\([0-9]+\))\s+binary/i', '$1', $sql); # "varchar(n) binary" cannot be followed by "binary" |
912 | | - $sql = preg_replace('/(var)?binary\(([0-9]+)\)/ie', '"varchar(".strlen(pow(2,$2)).")"', $sql); # use varchar(chars) not binary(bits) |
913 | | - $sql = preg_replace('/ (var)?binary/i', ' varchar', $sql); # use varchar not binary |
914 | | - $sql = preg_replace('/(varchar\([0-9]+\)(?! N))/', '$1 NULL', $sql); # MSSQL complains if NULL is put into a varchar |
915 | | - #$sql = preg_replace('/ binary/i',' varchar',$sql); # MSSQL binary's can't be assigned with strings, so use varchar's instead |
916 | | - #$sql = preg_replace('/(binary\([0-9]+\) (NOT NULL )?default) [\'"].*?[\'"]/i','$1 0',$sql); # binary default cannot be string |
917 | | - $sql = preg_replace('/[a-z]*(blob|text)([ ,])/i', 'text$2', $sql); # no BLOB types in MSSQL |
918 | | - $sql = preg_replace('/\).+?;/',');', $sql); # remove all table options |
919 | | - $sql = preg_replace('/ (un)?signed/i', '', $sql); |
920 | | - $sql = preg_replace('/ENUM\(.+?\)/','TEXT',$sql); # Make ENUM's into TEXT's |
921 | | - $sql = str_replace(' bool ', ' bit ', $sql); |
922 | | - $sql = str_replace('auto_increment', 'IDENTITY(1,1)', $sql); |
923 | | - #$sql = preg_replace('/NOT NULL(?! IDENTITY)/', 'NULL', $sql); # Allow NULL's for non IDENTITY columns |
924 | | - |
925 | | - # Tidy up and write file |
926 | | - $sql = preg_replace('/,\s*\)/s', "\n)", $sql); # Remove spurious commas left after INDEX removals |
927 | | - $sql = preg_replace('/^\s*^/m', '', $sql); # Remove empty lines |
928 | | - $sql = preg_replace('/;$/m', ";\n", $sql); # Separate each statement with an empty line |
929 | | - file_put_contents($mssql_tmpl, $sql); |
930 | | - } |
931 | | - |
932 | | - # Parse the MSSQL template replacing inline variables such as /*$wgDBprefix*/ |
933 | | - $err = $this->sourceFile($mssql_tmpl); |
934 | | - if ($err !== true) $this->reportQueryError($err,0,$sql,__FUNCTION__); |
935 | | - |
936 | | - # Use DatabasePostgres's code to populate interwiki from MySQL template |
937 | | - $f = fopen($mysql_iw,'r'); |
938 | | - if ($f == false) dieout("<li>Could not find the interwiki.sql file"); |
939 | | - $sql = "INSERT INTO {$this->mTablePrefix}interwiki(iw_prefix,iw_url,iw_local) VALUES "; |
940 | | - while (!feof($f)) { |
941 | | - $line = fgets($f,1024); |
942 | | - $matches = array(); |
943 | | - if (!preg_match('/^\s*(\(.+?),(\d)\)/', $line, $matches)) continue; |
944 | | - $this->query("$sql $matches[1],$matches[2])"); |
945 | | - } |
946 | | - } |
947 | | - |
948 | | - public function getSearchEngine() { |
949 | | - return "SearchEngineDummy"; |
950 | | - } |
951 | | -} |
952 | | - |
953 | | -/** |
954 | | - * @ingroup Database |
955 | | - */ |
956 | | -class MSSQLField extends MySQLField { |
957 | | - |
958 | | - function __construct() { |
959 | | - } |
960 | | - |
961 | | - static function fromText($db, $table, $field) { |
962 | | - $n = new MSSQLField; |
963 | | - $n->name = $field; |
964 | | - $n->tablename = $table; |
965 | | - return $n; |
966 | | - } |
967 | | - |
968 | | -} // end DatabaseMssql class |
969 | | - |
Index: trunk/phase3/includes/AutoLoader.php |
— | — | @@ -353,7 +353,6 @@ |
354 | 354 | 'ChronologyProtector' => 'includes/db/LBFactory.php', |
355 | 355 | 'Database' => 'includes/db/DatabaseMysql.php', |
356 | 356 | 'DatabaseBase' => 'includes/db/Database.php', |
357 | | - 'DatabaseMssql' => 'includes/db/DatabaseMssql.php', |
358 | 357 | 'DatabaseMysql' => 'includes/db/DatabaseMysql.php', |
359 | 358 | 'DatabaseOracle' => 'includes/db/DatabaseOracle.php', |
360 | 359 | 'DatabasePostgres' => 'includes/db/DatabasePostgres.php', |
— | — | @@ -372,7 +371,6 @@ |
373 | 372 | 'LoadBalancer' => 'includes/db/LoadBalancer.php', |
374 | 373 | 'LoadMonitor' => 'includes/db/LoadMonitor.php', |
375 | 374 | 'LoadMonitor_MySQL' => 'includes/db/LoadMonitor.php', |
376 | | - 'MSSQLField' => 'includes/db/DatabaseMssql.php', |
377 | 375 | 'MySQLField' => 'includes/db/Database.php', |
378 | 376 | 'MySQLMasterPos' => 'includes/db/DatabaseMysql.php', |
379 | 377 | 'ORABlob' => 'includes/db/DatabaseOracle.php', |
Index: trunk/phase3/config/Installer.php |
— | — | @@ -83,15 +83,6 @@ |
84 | 84 | 'serverless' => true |
85 | 85 | ); |
86 | 86 | |
87 | | -$ourdb['mssql'] = array( |
88 | | - 'fullname' => 'MSSQL', |
89 | | - 'havedriver' => 0, |
90 | | - 'compile' => 'mssql_not_ready', # Change to 'mssql' after includes/DatabaseMssql.php added; |
91 | | - 'bgcolor' => '#ffc0cb', |
92 | | - 'rootuser' => 'administrator', |
93 | | - 'serverless' => false |
94 | | -); |
95 | | - |
96 | 87 | $ourdb['ibm_db2'] = array( |
97 | 88 | 'fullname' => 'DB2', |
98 | 89 | 'havedriver' => 0, |
— | — | @@ -639,10 +630,6 @@ |
640 | 631 | ## SQLite specific |
641 | 632 | $conf->SQLiteDataDir = importPost( "SQLiteDataDir", "$IP/../data" ); |
642 | 633 | |
643 | | - ## MSSQL specific |
644 | | - // We need a second field so it doesn't overwrite the MySQL one |
645 | | - $conf->DBprefix2 = importPost( "DBprefix2" ); |
646 | | - |
647 | 634 | ## DB2 specific: |
648 | 635 | // New variable in order to have a different default port number |
649 | 636 | $conf->DBport_db2 = importPost( "DBport_db2", "50000" ); |
— | — | @@ -831,10 +818,7 @@ |
832 | 819 | $wgDBmwschema = $conf->DBdb2schema; |
833 | 820 | } |
834 | 821 | |
835 | | - if( $conf->DBprefix2 != '' ) { |
836 | | - // For MSSQL |
837 | | - $wgDBprefix = $conf->DBprefix2; |
838 | | - } elseif( $conf->DBprefix_ora != '' ) { |
| 822 | + if( $conf->DBprefix_ora != '' ) { |
839 | 823 | // For Oracle |
840 | 824 | $wgDBprefix = $conf->DBprefix_ora; |
841 | 825 | } |
— | — | @@ -1659,19 +1643,6 @@ |
1660 | 1644 | </div> |
1661 | 1645 | </fieldset> |
1662 | 1646 | |
1663 | | - <?php database_switcher('mssql'); ?> |
1664 | | - <div class="config-input"><?php |
1665 | | - aField( $conf, "DBprefix2", "Database table prefix:" ); |
1666 | | - ?></div> |
1667 | | - <div class="config-desc"> |
1668 | | - <p>If you need to share one database between multiple wikis, or |
1669 | | - between MediaWiki and another web application, you may choose to |
1670 | | - add a prefix to all the table names to avoid conflicts.</p> |
1671 | | - |
1672 | | - <p>Avoid exotic characters; something like <tt>mw_</tt> is good.</p> |
1673 | | - </div> |
1674 | | - </fieldset> |
1675 | | - |
1676 | 1647 | <?php database_switcher('ibm_db2'); ?> |
1677 | 1648 | <div class="config-input"><?php |
1678 | 1649 | aField( $conf, "DBport_db2", "Database port:" ); |
— | — | @@ -1873,10 +1844,6 @@ |
1874 | 1845 | $dbsettings = |
1875 | 1846 | "# SQLite-specific settings |
1876 | 1847 | \$wgSQLiteDataDir = \"{$sqliteDataDir}\";"; |
1877 | | - } elseif( $conf->DBtype == 'mssql' ) { |
1878 | | - $dbsettings = |
1879 | | -"# MSSQL specific settings |
1880 | | -\$wgDBprefix = \"{$slconf['DBprefix2']}\";"; |
1881 | 1848 | } elseif( $conf->DBtype == 'ibm_db2' ) { |
1882 | 1849 | $dbsettings = |
1883 | 1850 | "# DB2 specific settings |