Merge pull request #393 from tomhatzer/develop

Add custom mysql port support
This commit is contained in:
Samuel Denis-D'Ortun 2016-12-23 09:49:24 -05:00 committed by GitHub
commit 34c07f7d46
7 changed files with 26 additions and 5 deletions

View File

@ -4,4 +4,5 @@ define('PSM_DB_USER', 'db_user');
define('PSM_DB_PASS', 'db_pass');
define('PSM_DB_NAME', 'db_name');
define('PSM_DB_HOST', 'localhost');
define('PSM_DB_PORT', '3306');

View File

@ -27,6 +27,7 @@ To change these values correctly, only update the second parameter of the functi
define('PSM_DB_NAME', 'db_name');
define('PSM_DB_USER', 'db_user');
define('PSM_DB_PASS', 'db_user_password');
define('PSM_DB_PORT', '3306');
For example: to change your username you should ONLY change the 'db\_user' part.
Do NOT remove the quotes around your username as that will result in an error.

View File

@ -6,8 +6,9 @@ define('PSM_DB_USER', 'psm'); \
define('PSM_DB_PASS', 'psm'); \
define('PSM_DB_NAME', 'psm'); \
define('PSM_DB_HOST', 'localhost'); \
define('PSM_DB_PORT', '3306'); \
?>" > /var/www/default/psm/config.php
echo "<?php \
header('Location: /psm/index.php'); \
?>" > /var/www/default/index.php
?>" > /var/www/default/index.php

View File

@ -18,6 +18,7 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/sc
<parameter key="path.templates">%path.src%templates</parameter>
<parameter key="db.host" type="constant">PSM_DB_HOST</parameter>
<parameter key="db.port" type="constant">PSM_DB_PORT</parameter>
<parameter key="db.user" type="constant">PSM_DB_USER</parameter>
<parameter key="db.pass" type="constant">PSM_DB_PASS</parameter>
<parameter key="db.name" type="constant">PSM_DB_NAME</parameter>
@ -38,6 +39,7 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/sc
<argument>%db.user%</argument>
<argument>%db.pass%</argument>
<argument>%db.name%</argument>
<argument>%db.port%</argument>
</service>
<service id="event" class="Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher">

View File

@ -121,6 +121,7 @@ class InstallController extends AbstractController {
$config = array(
'host' => 'localhost',
'port' => '3306',
'name' => '',
'user' => '',
'pass' => '',
@ -143,7 +144,8 @@ class InstallController extends AbstractController {
$config['host'],
$config['user'],
$config['pass'],
$config['name']
$config['name'],
$config['port']
);
if($this->db->status()) {
@ -307,6 +309,7 @@ class InstallController extends AbstractController {
'pass' => '',
'name' => '',
'host' => '',
'port' => '3306'
);
$pattern = "/define\('SM_DB_{key}', '(.*?)'/u";

View File

@ -35,6 +35,12 @@ class Database {
*/
protected $db_host;
/**
* DB port
* @var string $db_port
*/
protected $db_port = 3306;
/**
* DB name
* @var string $db_name
@ -81,9 +87,10 @@ class Database {
* @param string $pass
* @param string $db
*/
function __construct($host = null, $user = null, $pass = null, $db = null) {
function __construct($host = null, $user = null, $pass = null, $db = null, $port = null) {
if($host != null && $user != null && $pass !== null && $db != null) {
$this->db_host = $host;
$this->db_port = $port || 3306;
$this->db_name = $db;
$this->db_user = $user;
$this->db_pass = $pass;
@ -498,7 +505,7 @@ class Database {
// Initizale connection
try {
$this->pdo = new \PDO(
'mysql:host='.$this->db_host.';dbname='.$this->db_name.';charset=utf8',
'mysql:host='.$this->db_host.';port='.$this->db_port.';dbname='.$this->db_name.';charset=utf8',
$this->db_user,
$this->db_pass
);

View File

@ -17,6 +17,12 @@
<input type="text" id="host" name="host" value="{{ host }}" />
</div>
</div>
<div class="control-group">
<label class="control-label" for="host">Database port</label>
<div class="controls">
<input type="text" id="port" name="port" value="{{ port }}" />
</div>
</div>
<div class="control-group">
<label class="control-label" for="name">Database name</label>
<div class="controls">
@ -60,4 +66,4 @@
</div>
{% endif %}
</div>
{% endblock %}
{% endblock %}