Skip to content

Commit

Permalink
Support custom MySQL ports
Browse files Browse the repository at this point in the history
  • Loading branch information
Alkarex committed Sep 5, 2016
1 parent 9fac3ac commit 91e082c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ function printStep3() {
<div class="form-group">
<label class="group-name" for="host"><?php echo _t('install.bdd.host'); ?></label>
<div class="group-controls">
<input type="text" id="host" name="host" pattern="[0-9A-Za-z_.-]{1,64}" value="<?php echo isset($_SESSION['bd_host']) ? $_SESSION['bd_host'] : $system_default_config->db['host']; ?>" tabindex="2" />
<input type="text" id="host" name="host" pattern="[0-9A-Za-z_.-]{1,64}(:[0-9]{2,5})?" value="<?php echo isset($_SESSION['bd_host']) ? $_SESSION['bd_host'] : $system_default_config->db['host']; ?>" tabindex="2" />
</div>
</div>

Expand Down
6 changes: 5 additions & 1 deletion lib/Minz/ModelPdo.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,17 @@ public function __construct($currentUser = null) {
self::$sharedCurrentUser = $currentUser;

$driver_options = isset($conf->db['pdo_options']) && is_array($conf->db['pdo_options']) ? $conf->db['pdo_options'] : array();
$dbServer = parse_url('db://' . $db['host']);

try {
$type = $db['type'];
if ($type === 'mysql') {
$string = 'mysql:host=' . $db['host']
$string = 'mysql:host=' . $dbServer['host']
. ';dbname=' . $db['base']
. ';charset=utf8mb4';
if (!empty($dbServer['port'])) {
$string .= ';port=' . $dbServer['port'];
}
$driver_options[PDO::MYSQL_ATTR_INIT_COMMAND] = 'SET NAMES utf8mb4';
$this->prefix = $db['prefix'] . $currentUser . '_';
} elseif ($type === 'sqlite') {
Expand Down

0 comments on commit 91e082c

Please sign in to comment.