Merge pull request #393 from tomhatzer/develop
Add custom mysql port support
This commit is contained in:
commit
34c07f7d46
|
@ -4,4 +4,5 @@ define('PSM_DB_USER', 'db_user');
|
||||||
define('PSM_DB_PASS', 'db_pass');
|
define('PSM_DB_PASS', 'db_pass');
|
||||||
define('PSM_DB_NAME', 'db_name');
|
define('PSM_DB_NAME', 'db_name');
|
||||||
define('PSM_DB_HOST', 'localhost');
|
define('PSM_DB_HOST', 'localhost');
|
||||||
|
define('PSM_DB_PORT', '3306');
|
||||||
|
|
||||||
|
|
|
@ -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_NAME', 'db_name');
|
||||||
define('PSM_DB_USER', 'db_user');
|
define('PSM_DB_USER', 'db_user');
|
||||||
define('PSM_DB_PASS', 'db_user_password');
|
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.
|
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.
|
Do NOT remove the quotes around your username as that will result in an error.
|
||||||
|
|
|
@ -6,8 +6,9 @@ define('PSM_DB_USER', 'psm'); \
|
||||||
define('PSM_DB_PASS', 'psm'); \
|
define('PSM_DB_PASS', 'psm'); \
|
||||||
define('PSM_DB_NAME', 'psm'); \
|
define('PSM_DB_NAME', 'psm'); \
|
||||||
define('PSM_DB_HOST', 'localhost'); \
|
define('PSM_DB_HOST', 'localhost'); \
|
||||||
|
define('PSM_DB_PORT', '3306'); \
|
||||||
?>" > /var/www/default/psm/config.php
|
?>" > /var/www/default/psm/config.php
|
||||||
|
|
||||||
echo "<?php \
|
echo "<?php \
|
||||||
header('Location: /psm/index.php'); \
|
header('Location: /psm/index.php'); \
|
||||||
?>" > /var/www/default/index.php
|
?>" > /var/www/default/index.php
|
||||||
|
|
|
@ -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="path.templates">%path.src%templates</parameter>
|
||||||
|
|
||||||
<parameter key="db.host" type="constant">PSM_DB_HOST</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.user" type="constant">PSM_DB_USER</parameter>
|
||||||
<parameter key="db.pass" type="constant">PSM_DB_PASS</parameter>
|
<parameter key="db.pass" type="constant">PSM_DB_PASS</parameter>
|
||||||
<parameter key="db.name" type="constant">PSM_DB_NAME</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.user%</argument>
|
||||||
<argument>%db.pass%</argument>
|
<argument>%db.pass%</argument>
|
||||||
<argument>%db.name%</argument>
|
<argument>%db.name%</argument>
|
||||||
|
<argument>%db.port%</argument>
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
<service id="event" class="Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher">
|
<service id="event" class="Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher">
|
||||||
|
|
|
@ -121,6 +121,7 @@ class InstallController extends AbstractController {
|
||||||
|
|
||||||
$config = array(
|
$config = array(
|
||||||
'host' => 'localhost',
|
'host' => 'localhost',
|
||||||
|
'port' => '3306',
|
||||||
'name' => '',
|
'name' => '',
|
||||||
'user' => '',
|
'user' => '',
|
||||||
'pass' => '',
|
'pass' => '',
|
||||||
|
@ -143,7 +144,8 @@ class InstallController extends AbstractController {
|
||||||
$config['host'],
|
$config['host'],
|
||||||
$config['user'],
|
$config['user'],
|
||||||
$config['pass'],
|
$config['pass'],
|
||||||
$config['name']
|
$config['name'],
|
||||||
|
$config['port']
|
||||||
);
|
);
|
||||||
|
|
||||||
if($this->db->status()) {
|
if($this->db->status()) {
|
||||||
|
@ -307,6 +309,7 @@ class InstallController extends AbstractController {
|
||||||
'pass' => '',
|
'pass' => '',
|
||||||
'name' => '',
|
'name' => '',
|
||||||
'host' => '',
|
'host' => '',
|
||||||
|
'port' => '3306'
|
||||||
);
|
);
|
||||||
$pattern = "/define\('SM_DB_{key}', '(.*?)'/u";
|
$pattern = "/define\('SM_DB_{key}', '(.*?)'/u";
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,12 @@ class Database {
|
||||||
*/
|
*/
|
||||||
protected $db_host;
|
protected $db_host;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DB port
|
||||||
|
* @var string $db_port
|
||||||
|
*/
|
||||||
|
protected $db_port = 3306;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DB name
|
* DB name
|
||||||
* @var string $db_name
|
* @var string $db_name
|
||||||
|
@ -81,9 +87,10 @@ class Database {
|
||||||
* @param string $pass
|
* @param string $pass
|
||||||
* @param string $db
|
* @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) {
|
if($host != null && $user != null && $pass !== null && $db != null) {
|
||||||
$this->db_host = $host;
|
$this->db_host = $host;
|
||||||
|
$this->db_port = $port || 3306;
|
||||||
$this->db_name = $db;
|
$this->db_name = $db;
|
||||||
$this->db_user = $user;
|
$this->db_user = $user;
|
||||||
$this->db_pass = $pass;
|
$this->db_pass = $pass;
|
||||||
|
@ -498,7 +505,7 @@ class Database {
|
||||||
// Initizale connection
|
// Initizale connection
|
||||||
try {
|
try {
|
||||||
$this->pdo = new \PDO(
|
$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_user,
|
||||||
$this->db_pass
|
$this->db_pass
|
||||||
);
|
);
|
||||||
|
|
|
@ -17,6 +17,12 @@
|
||||||
<input type="text" id="host" name="host" value="{{ host }}" />
|
<input type="text" id="host" name="host" value="{{ host }}" />
|
||||||
</div>
|
</div>
|
||||||
</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">
|
<div class="control-group">
|
||||||
<label class="control-label" for="name">Database name</label>
|
<label class="control-label" for="name">Database name</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
|
@ -60,4 +66,4 @@
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Loading…
Reference in New Issue