mirror of
https://github.com/moodle/moodle.git
synced 2025-04-22 17:02:03 +02:00
MDL-30779 add port and socket to dbtansfer tool
This commit is contained in:
parent
f89a83b87b
commit
47651a4d8c
@ -57,6 +57,8 @@ class database_transfer_form extends moodleform {
|
||||
$mform->addElement('text', 'dbuser', get_string('user'));
|
||||
$mform->addElement('text', 'dbpass', get_string('password'));
|
||||
$mform->addElement('text', 'prefix', get_string('dbprefix', 'install'));
|
||||
$mform->addElement('text', 'dbport', get_string('dbport', 'install'));
|
||||
$mform->addElement('text', 'dbsocket', get_string('databasesocket', 'install'));
|
||||
|
||||
$mform->addRule('dbhost', get_string('required'), 'required', null);
|
||||
$mform->addRule('dbname', get_string('required'), 'required', null);
|
||||
|
@ -40,7 +40,14 @@ if ($data = $form->get_data()) {
|
||||
// Connect to the other database.
|
||||
list($dbtype, $dblibrary) = explode('/', $data->driver);
|
||||
$targetdb = moodle_database::get_driver_instance($dbtype, $dblibrary);
|
||||
if (!$targetdb->connect($data->dbhost, $data->dbuser, $data->dbpass, $data->dbname, $data->prefix, null)) {
|
||||
$dboptions = array();
|
||||
if ($data->dbport) {
|
||||
$dboptions['dbport'] = $data->dbport;
|
||||
}
|
||||
if ($data->dbsocket) {
|
||||
$dboptions['dbsocket'] = $data->dbsocket;
|
||||
}
|
||||
if (!$targetdb->connect($data->dbhost, $data->dbuser, $data->dbpass, $data->dbname, $data->prefix, $dboptions)) {
|
||||
throw new dbtransfer_exception('notargetconectexception', null, "$CFG->wwwroot/$CFG->admin/tool/dbtransfer/");
|
||||
}
|
||||
if ($targetdb->get_tables()) {
|
||||
|
@ -160,6 +160,7 @@ $string['dbconnectionerror'] = 'We could not connect to the database you specifi
|
||||
$string['dbcreationerror'] = 'Database creation error. Could not create the given database name with the settings provided';
|
||||
$string['dbhost'] = 'Host server';
|
||||
$string['dbpass'] = 'Password';
|
||||
$string['dbport'] = 'Port';
|
||||
$string['dbprefix'] = 'Tables prefix';
|
||||
$string['dbtype'] = 'Type';
|
||||
$string['dbwrongencoding'] = 'The selected database is running under one non-recommended encoding ({$a}). It would be better to use one Unicode (UTF-8) encoded database instead. Anyway, you can bypass this test by selecting the "Skip DB Encoding Test" check below, but you could experience problems in the future.';
|
||||
|
Loading…
x
Reference in New Issue
Block a user