Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
UserAdminV2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
庄欣
UserAdminV2
Commits
fe0b4b28
Commit
fe0b4b28
authored
Feb 17, 2012
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleaning up code.
parent
33e49146
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
27 deletions
+28
-27
laravel/database/connectors/mysql.php
+13
-11
laravel/database/connectors/postgres.php
+8
-11
laravel/database/connectors/sqlserver.php
+1
-2
laravel/database/grammar.php
+4
-1
laravel/database/query.php
+2
-2
No files found.
laravel/database/connectors/mysql.php
View file @
fe0b4b28
...
...
@@ -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
();
...
...
laravel/database/connectors/postgres.php
View file @
fe0b4b28
...
...
@@ -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
();
...
...
laravel/database/connectors/sqlserver.php
View file @
fe0b4b28
...
...
@@ -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
}
"
;
...
...
laravel/database/grammar.php
View file @
fe0b4b28
...
...
@@ -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
...
...
laravel/database/query.php
View file @
fe0b4b28
...
...
@@ -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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment