This commit is contained in:
Andrew Nicols 2018-04-09 09:26:23 +08:00
commit 9ec2b3e639
12 changed files with 27 additions and 1638 deletions

View File

@ -219,7 +219,6 @@ $databases = array('mysqli' => moodle_database::get_driver_instance('mysqli', 'n
'pgsql' => moodle_database::get_driver_instance('pgsql', 'native'),
'oci' => moodle_database::get_driver_instance('oci', 'native'),
'sqlsrv' => moodle_database::get_driver_instance('sqlsrv', 'native'), // MS SQL*Server PHP driver
'mssql' => moodle_database::get_driver_instance('mssql', 'native'), // FreeTDS driver
);
foreach ($databases as $type=>$database) {
if ($database->driver_installed() !== true) {

View File

@ -44,8 +44,7 @@ class helper {
'native/mariadb' => \moodle_database::get_driver_instance('mariadb', 'native')->get_name(),
'native/pgsql' => \moodle_database::get_driver_instance('pgsql', 'native')->get_name(),
'native/oci' => \moodle_database::get_driver_instance('oci', 'native')->get_name(),
'native/sqlsrv' => \moodle_database::get_driver_instance('sqlsrv', 'native')->get_name(),
'native/mssql' => \moodle_database::get_driver_instance('mssql', 'native')->get_name()
'native/sqlsrv' => \moodle_database::get_driver_instance('sqlsrv', 'native')->get_name()
);
}

View File

@ -97,11 +97,7 @@ class auth_db_testcase extends advanced_testcase {
break;
case 'mssql':
if (get_class($DB) == 'mssql_native_moodle_database') {
set_config('type', 'mssql_n', 'auth_db');
} else {
set_config('type', 'mssqlnative', 'auth_db');
}
set_config('type', 'mssqlnative', 'auth_db');
set_config('sybasequoting', '1', 'auth_db');
break;

View File

@ -38,7 +38,7 @@ $CFG = new stdClass();
// will be stored. This database must already have been created //
// and a username/password created to access it. //
$CFG->dbtype = 'pgsql'; // 'pgsql', 'mariadb', 'mysqli', 'mssql', 'sqlsrv' or 'oci'
$CFG->dbtype = 'pgsql'; // 'pgsql', 'mariadb', 'mysqli', 'sqlsrv' or 'oci'
$CFG->dblibrary = 'native'; // 'native' only at the moment
$CFG->dbhost = 'localhost'; // eg 'localhost' or 'db.isp.com' or IP
$CFG->dbname = 'moodle'; // database name, eg moodle

View File

@ -96,11 +96,7 @@ class enrol_database_testcase extends advanced_testcase {
break;
case 'mssql':
if (get_class($DB) == 'mssql_native_moodle_database') {
set_config('dbtype', 'mssql_n', 'enrol_database');
} else {
set_config('dbtype', 'mssqlnative', 'enrol_database');
}
set_config('dbtype', 'mssqlnative', 'enrol_database');
set_config('dbsybasequoting', '1', 'enrol_database');
break;

View File

@ -483,7 +483,6 @@ if ($config->stage == INSTALL_DATABASETYPE) {
'pgsql' => moodle_database::get_driver_instance('pgsql', 'native'),
'oci' => moodle_database::get_driver_instance('oci', 'native'),
'sqlsrv' => moodle_database::get_driver_instance('sqlsrv', 'native'), // MS SQL*Server PHP driver
'mssql' => moodle_database::get_driver_instance('mssql', 'native'), // FreeTDS driver
);
echo '<div class="userinput">';

View File

@ -167,7 +167,6 @@ $string['memorylimithelp'] = '<p>The PHP memory limit for your server is current
<p>However, on some servers this will prevent <b>all</b> PHP pages from working
(you will see errors when you look at pages) so you\'ll have to remove the .htaccess file.</p></li>
</ol>';
$string['mssqlextensionisnotpresentinphp'] = 'PHP has not been properly configured with the MSSQL extension so that it can communicate with SQL*Server. Please check your php.ini file or recompile PHP.';
$string['mysqliextensionisnotpresentinphp'] = 'PHP has not been properly configured with the MySQLi extension for it to communicate with MySQL. Please check your php.ini file or recompile PHP.';
$string['nativemariadb'] = 'MariaDB (native/mariadb)';
$string['nativemariadbhelp'] = '<p>The database is where most of the Moodle settings and data are stored and must be configured here.</p>
@ -180,9 +179,6 @@ $string['nativemysqlihelp'] = '<p>The database is where most of the Moodle setti
<p>The database name, username, and password are required fields; table prefix is optional.</p>
<p>The database name may contain only alphanumeric characters, dollar ($) and underscore (_).</p>
<p>If the database currently does not exist, and the user you specify has permission, Moodle will attempt to create a new database with the correct permissions and settings.</p>';
$string['nativemssql'] = 'SQL*Server FreeTDS (native/mssql)';
$string['nativemssqlhelp'] = 'Now you need to configure the database where most Moodle data will be stored.
This database must already have been created and a username and password created to access it. Table prefix is mandatory.';
$string['nativeoci'] = 'Oracle (native/oci)';
$string['nativeocihelp'] = 'Now you need to configure the database where most Moodle data will be stored.
This database must already have been created and a username and password created to access it. Table prefix is mandatory.';
@ -254,3 +250,4 @@ $string['welcomep60'] = 'The following pages will lead you through some easy to
$string['welcomep70'] = 'Click the "Next" button below to continue with the set up of <strong>Moodle</strong>.';
$string['wwwroot'] = 'Web address';
$string['wwwrooterror'] = 'The \'Web Address\' does not appear to be valid - this Moodle installation doesn\'t appear to be there. The value below has been reset.';
// Deprecated since 3.4.

File diff suppressed because it is too large Load Diff

View File

@ -1,94 +0,0 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* MSSQL specific recordset.
*
* @package core_dml
* @copyright 2009 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
require_once(__DIR__.'/moodle_recordset.php');
class mssql_native_moodle_recordset extends moodle_recordset {
protected $rsrc;
protected $current;
public function __construct($rsrc) {
$this->rsrc = $rsrc;
$this->current = $this->fetch_next();
}
public function __destruct() {
$this->close();
}
private function fetch_next() {
if (!$this->rsrc) {
return false;
}
if (!$row = mssql_fetch_assoc($this->rsrc)) {
mssql_free_result($this->rsrc);
$this->rsrc = null;
return false;
}
$row = array_change_key_case($row, CASE_LOWER);
// Moodle expects everything from DB as strings.
foreach ($row as $k=>$v) {
if (is_null($v)) {
continue;
}
if (!is_string($v)) {
$row[$k] = (string)$v;
}
}
return $row;
}
public function current() {
return (object)$this->current;
}
public function key() {
// return first column value as key
if (!$this->current) {
return false;
}
$key = reset($this->current);
return $key;
}
public function next() {
$this->current = $this->fetch_next();
}
public function valid() {
return !empty($this->current);
}
public function close() {
if ($this->rsrc) {
mssql_free_result($this->rsrc);
$this->rsrc = null;
}
$this->current = null;
}
}

View File

@ -1,51 +0,0 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* MSSQL specific temptables store. Needed because temporary tables
* are named differently than normal tables. Also used to be able to retrieve
* temp table names included in the get_tables() method of the DB.
*
* @package core_dml
* @copyright 2009 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
require_once(__DIR__.'/moodle_temptables.php');
class mssql_native_moodle_temptables extends moodle_temptables {
/**
* Add one temptable to the store.
*
* Overriden because MSSQL requires to add # for local (session) temporary
* tables before the prefix.
*
* Given one moodle temptable name (without prefix), add it to the store, with the
* key being the original moodle name and the value being the real db temptable name
* already prefixed
*
* Override and use this *only* if the database requires modification in the table name.
*
* @param string $tablename name without prefix of the table created as temptable
*/
public function add_temptable($tablename) {
// TODO: throw exception if exists: if ($this->is_temptable...
$this->temptables[$tablename] = '#' . $this->prefix . $tablename;
}
}

View File

@ -26,7 +26,7 @@
defined('MOODLE_INTERNAL') || die();
require_once(__DIR__.'/mssql_native_moodle_temptables.php');
require_once(__DIR__.'/moodle_temptables.php');
/**
* This class is not specific to the SQL Server Native Driver but rather
@ -36,4 +36,24 @@ require_once(__DIR__.'/mssql_native_moodle_temptables.php');
* @copyright 2009 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v2 or later
*/
class sqlsrv_native_moodle_temptables extends mssql_native_moodle_temptables {}
class sqlsrv_native_moodle_temptables extends moodle_temptables {
/**
* Add one temptable to the store.
*
* Overriden because SQLSRV requires to add # for local (session) temporary
* tables before the prefix.
*
* Given one moodle temptable name (without prefix), add it to the store, with the
* key being the original moodle name and the value being the real db temptable name
* already prefixed
*
* Override and use this *only* if the database requires modification in the table name.
*
* @param string $tablename name without prefix of the table created as temptable
*/
public function add_temptable($tablename) {
// TODO: throw exception if exists: if ($this->is_temptable...
$this->temptables[$tablename] = '#' . $this->prefix . $tablename;
}
}

View File

@ -314,10 +314,6 @@ function setup_DB() {
$CFG->dbtype = 'pgsql';
break;
case 'mssql_n':
$CFG->dbtype = 'mssql';
break;
case 'oci8po':
$CFG->dbtype = 'oci';
break;