Permalink
Browse files

MDL-30779 add port and socket to dbtansfer tool

  • Loading branch information...
1 parent 1f3933b commit c2ca1a3793785c1d75120aa6f9c2076db0bba32d @skodak skodak committed with Sam Hemelryk Dec 16, 2011
Showing with 11 additions and 1 deletion.
  1. +2 −0 admin/tool/dbtransfer/database_transfer_form.php
  2. +8 −1 admin/tool/dbtransfer/index.php
  3. +1 −0 lang/en/install.php
@@ -57,6 +57,8 @@ function definition() {
$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 @@
// 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()) {
View
@@ -160,6 +160,7 @@
$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.';

0 comments on commit c2ca1a3

Please sign in to comment.