Permalink
Browse files

Allow PDO_MySQL to connect to sockets

  • Loading branch information...
1 parent 85d1102 commit fc499f427c6d44ab787fe3b45db851151fed13be @haraldpdl haraldpdl committed Aug 3, 2011
Showing with 9 additions and 3 deletions.
  1. +9 −3 osCommerce/OM/Core/PDO/MySQL/Standard.php
@@ -33,10 +33,16 @@ public function __construct($server, $username, $password, $database, $port, $dr
}
public function connect() {
- $dsn = 'mysql:dbname=' . $this->_database . ';host=' . $this->_server;
+ $dsn = 'mysql:dbname=' . $this->_database;
- if ( !empty($this->_port) ) {
- $dsn .= ';port=' . $this->_port;
+ if ( (strpos($this->_server, '/') !== false) || (strpos($this->_server, '\\') !== false) ) {
+ $dsn .= ';unix_socket=' . $this->_server;
+ } else {
+ $dsn .= ';host=' . $this->_server;
+
+ if ( !empty($this->_port) ) {
+ $dsn .= ';port=' . $this->_port;
+ }
}
$this->_connected = true;

0 comments on commit fc499f4

Please sign in to comment.