cleaning up code.
This commit is contained in:
parent
33e4914634
commit
fe0b4b287d
|
@ -12,24 +12,26 @@ public function connect($config)
|
|||
{
|
||||
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();
|
||||
|
|
|
@ -12,24 +12,21 @@ public function connect($config)
|
|||
{
|
||||
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();
|
||||
|
|
|
@ -26,8 +26,7 @@ public function connect($config)
|
|||
|
||||
// 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}";
|
||||
|
|
|
@ -59,7 +59,10 @@ public function wrap($value)
|
|||
// 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
|
||||
|
|
|
@ -150,7 +150,7 @@ public function join($table, $column1, $operator = null, $column2 = null, $type
|
|||
{
|
||||
// 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 @@ private function dynamic_where($method, $parameters)
|
|||
//
|
||||
// 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;
|
||||
|
|
Loading…
Reference in New Issue