Skip to content

Commit

Permalink
New feature #07664: Allow unix_socket on installation and connexion s…
Browse files Browse the repository at this point in the history
…tring (use socket directly in DB location)

Dev: maybe adding more protocol : http://dev.mysql.com/doc/refman/5.5/en//connecting.html#option_general_protocol
Dev: but seem needed only for some ... hoster
  • Loading branch information
Shnoulle committed Mar 26, 2013
1 parent 7df1d6f commit 7f74b1b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions application/controllers/InstallerController.php
Expand Up @@ -1104,7 +1104,11 @@ function _getDsn($sDatabaseType, $sDatabaseLocation, $sDatabasePort, $sDatabaseN
switch ($sDatabaseType) {
case 'mysql':
case 'mysqli':
$dsn = "mysql:host={$sDatabaseLocation};port={$sDatabasePort};dbname={$sDatabaseName};";
// MySQL allow unix_socket for database location, then test if $sDatabaseLocation start with "/"
if(substr($sDatabaseLocation,0,1)=="/")
$dsn = "mysql:unix_socket={$sDatabaseLocation};dbname={$sDatabaseName};";
else
$dsn = "mysql:host={$sDatabaseLocation};port={$sDatabasePort};dbname={$sDatabaseName};";
break;
case 'pgsql':
if (empty($sDatabasePwd))
Expand All @@ -1129,7 +1133,6 @@ function _getDsn($sDatabaseType, $sDatabaseLocation, $sDatabasePort, $sDatabaseN
default:
throw new Exception(sprintf('Unknown database type "%s".', $sDatabaseType));
}

return $dsn;
}

Expand Down
2 changes: 1 addition & 1 deletion application/views/installer/dbconfig_view.php
Expand Up @@ -34,7 +34,7 @@
<tr>
<td style="width: 428px;">
<b><?php echo CHtml::activeLabelEx($model, 'dblocation', array('label' => $clang->gT("Database location"))); ?></b><br />
<div class="description-field"><?php $clang->eT('Set this to the IP/net location of your database server. In most cases "localhost" will work.'); ?> </div>
<div class="description-field"><?php $clang->eT('Set this to the IP/net location of your database server. In most cases "localhost" will work. You can force Unix socket with complete socket path.'); ?> </div>
</td>
<td style="width: 224px;" align="right"><?php echo CHtml::activeTextField($model, 'dblocation', array('required' => 'required')) ?></td>
</tr>
Expand Down

0 comments on commit 7f74b1b

Please sign in to comment.