diff --git a/laravel/database/connectors/mysql.php b/laravel/database/connectors/mysql.php index ad4cc12e..568504e0 100644 --- a/laravel/database/connectors/mysql.php +++ b/laravel/database/connectors/mysql.php @@ -12,24 +12,26 @@ class MySQL extends Connector { { extract($config); - // Format the initial MySQL PDO connection string. These options are required - // for every MySQL connection that is established. The connection strings - // have the following convention: "mysql:host=hostname;dbname=database" $dsn = "mysql:host={$host};dbname={$database}"; - // Check for any optional MySQL PDO options. These options are not required - // to establish a PDO connection; however, may be needed in certain server - // or hosting environments used by the developer. - foreach (array('port', 'unix_socket') as $key) + // The developer has the freedom of specifying a port for the MySQL database + // or the default port (3306) will be used to make the connection by PDO. + // The Unix socket may also be specified if necessary. + if (isset($config['port'])) { - if (isset($config[$key])) - { - $dsn .= ";{$key}={$config[$key]}"; - } + $dsn .= ";port={$config['port']}"; + } + + if (isset($config['unix_socket'])) + { + $dsn .= ";unix_socket={$config['unix_socket']}"; } $connection = new PDO($dsn, $username, $password, $this->options($config)); + // If a character set has been specified, we'll execute a query against + // the database to set the correct character set. By default, this is + // set to UTF-8 which should be fine for most scenarios. if (isset($config['charset'])) { $connection->prepare("SET NAMES '{$config['charset']}'")->execute(); diff --git a/laravel/database/connectors/postgres.php b/laravel/database/connectors/postgres.php index d128583c..233914fd 100644 --- a/laravel/database/connectors/postgres.php +++ b/laravel/database/connectors/postgres.php @@ -12,24 +12,21 @@ class Postgres extends Connector { { extract($config); - // Format the initial Postgres PDO connection string. These options are required - // for every Postgres connection that is established. The connection strings - // have the following convention: "pgsql:host=hostname;dbname=database" $dsn = "pgsql:host={$host};dbname={$database}"; - // Check for any optional Postgres PDO options. These options are not required - // to establish a PDO connection; however, may be needed in certain server - // or hosting environments used by the developer. - foreach (array('port') as $key => $value) + // The developer has the freedom of specifying a port for the PostgresSQL + // database or the default port (5432) will be used by PDO to create the + // connection to the database for the developer. + if (isset($config['port'])) { - if (isset($config[$key])) - { - $dsn .= ";{$key}={$value}"; - } + $dsn .= ";port={$config['port']}"; } $connection = new PDO($dsn, $username, $password, $this->options($config)); + // If a character set has been specified, we'll execute a query against + // the database to set the correct character set. By default, this is + // set to UTF-8 which should be fine for most scenarios. if (isset($config['charset'])) { $connection->prepare("SET NAMES '{$config['charset']}'")->execute(); diff --git a/laravel/database/connectors/sqlserver.php b/laravel/database/connectors/sqlserver.php index 8e57b99c..29c6929b 100644 --- a/laravel/database/connectors/sqlserver.php +++ b/laravel/database/connectors/sqlserver.php @@ -26,8 +26,7 @@ class SQLServer extends Connector { // Format the SQL Server connection string. This connection string format can // also be used to connect to Azure SQL Server databases. The port is defined - // directly after the server name, so we'll create that and then create the - // final DSN string to pass to PDO. + // directly after the server name, so we'll create that first. $port = (isset($port)) ? ','.$port : ''; $dsn = "sqlsrv:Server={$host}{$port};Database={$database}"; diff --git a/laravel/database/grammar.php b/laravel/database/grammar.php index 079a4452..e47fb360 100644 --- a/laravel/database/grammar.php +++ b/laravel/database/grammar.php @@ -59,7 +59,10 @@ abstract class Grammar { // Expressions should be injected into the query as raw strings so // so we do not want to wrap them in any way. We will just return // the string value from the expression to be included. - if ($value instanceof Expression) return $value->get(); + if ($value instanceof Expression) + { + return $value->get(); + } // If the value being wrapped contains a column alias, we need to // wrap it a little differently as each segment must be wrapped diff --git a/laravel/database/query.php b/laravel/database/query.php index e189dc1f..d0503d6a 100644 --- a/laravel/database/query.php +++ b/laravel/database/query.php @@ -150,7 +150,7 @@ class Query { { // If the "column" is really an instance of a Closure, the developer is // trying to create a join with a complex "ON" clause. So, we will add - // the join, and then call the Closure with the join. + // the join, and then call the Closure with the join/ if ($column1 instanceof Closure) { $this->joins[] = new Query\Join($type, $table); @@ -435,7 +435,7 @@ class Query { // // The index variable helps us get the correct parameter value // for the where condition. We increment it each time we add - // a condition to the query. + // a condition to the query's where. $connector = 'AND'; $index = 0;