Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
syncEnrollments
Project
Project
Details
Activity
Releases
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yeray Santana Hualde
syncEnrollments
Commits
8688270f
Commit
8688270f
authored
Sep 14, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed database bugs.
parent
15449c34
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
53 deletions
+23
-53
database.php
application/config/database.php
+5
-4
connection.php
laravel/database/connection.php
+4
-4
model.php
laravel/database/eloquent/model.php
+1
-0
grammar.php
laravel/database/grammars/grammar.php
+13
-45
No files found.
application/config/database.php
View file @
8688270f
...
...
@@ -43,16 +43,17 @@ return array(
'sqlite'
=>
function
(
$config
)
{
return
new
PDO
(
'sqlite:'
.
DATABASE_PATH
.
'application.sqlite'
,
null
,
null
,
$config
[
'options'
]);
}
}
,
'mysql'
=>
function
(
$config
)
{
return
new
PDO
(
'mysql:host=localhost;dbname=database'
,
'username'
,
'password'
,
$config
[
'options'
]);
}
}
,
'pgsql'
=>
array
(
'pgsql'
=>
function
(
$config
)
{
return
new
PDO
(
'pgsql:host=localhost;dbname=database'
,
'username'
,
'password'
,
$config
[
'options'
]);
)
,
}
,
),
...
...
laravel/database/connection.php
View file @
8688270f
...
...
@@ -105,7 +105,7 @@ class Connection {
*/
public
function
table
(
$table
)
{
return
new
Query
(
$this
,
$this
->
gramm
e
r
(),
$table
);
return
new
Query
(
$this
,
$this
->
gramm
a
r
(),
$table
);
}
/**
...
...
@@ -118,13 +118,13 @@ class Connection {
switch
(
$this
->
driver
())
{
case
'mysql'
:
return
new
Queries\
Grammars\MySQL
;
return
new
Grammars\MySQL
;
case
'pgsql'
:
return
new
Queries\
Grammars\Postgres
;
return
new
Grammars\Postgres
;
default
:
return
new
Queries\
Grammars\Grammar
;
return
new
Grammars\Grammar
;
}
}
...
...
laravel/database/eloquent/model.php
View file @
8688270f
<?php
namespace
Laravel\Database\Eloquent
;
use
Laravel\IoC
;
use
Laravel\Str
;
use
Laravel\Inflector
;
...
...
laravel/database/grammars/grammar.php
View file @
8688270f
...
...
@@ -7,9 +7,6 @@ class Grammar {
/**
* Compile a SQL SELECT statment from a Query instance.
*
* This query instance will be examined and the proper SQL syntax will be returned as a string.
* This class may be overridden to accommodate syntax differences between various database systems.
*
* @param Query $query
* @return string
*/
...
...
@@ -37,26 +34,12 @@ class Grammar {
/**
* Compile the query SELECT clause.
*
* For convenience, the entire query object is passed to the method. This to account for
* database systems who put the LIMIT amount in the SELECT clause.
*
* @param Query $query
* @return string
*/
public
function
compile_select
(
Query
$query
)
{
return
((
$query
->
distinct
)
?
'SELECT DISTINCT '
:
'SELECT '
)
.
$this
->
wrap_columns
(
$query
->
select
);
}
/**
* Wrap and comma-delimit a set of SELECT columns.
*
* @param array $columns
* @return string
*/
public
function
wrap_columns
(
$columns
)
protected
function
compile_select
(
Query
$query
)
{
return
implode
(
', '
,
array_map
(
array
(
$this
,
'wrap'
),
$columns
));
return
((
$query
->
distinct
)
?
'SELECT DISTINCT '
:
'SELECT '
)
.
implode
(
', '
,
array_map
(
array
(
$this
,
'wrap'
),
$query
->
select
));
}
/**
...
...
@@ -66,7 +49,7 @@ class Grammar {
* @param string $column
* @return string
*/
p
ublic
function
compile_aggregate
(
$aggregator
,
$column
)
p
rotected
function
compile_aggregate
(
$aggregator
,
$column
)
{
return
'SELECT '
.
$aggregator
.
'('
.
$this
->
wrap
(
$column
)
.
') AS '
.
$this
->
wrap
(
'aggregate'
);
}
...
...
@@ -79,7 +62,7 @@ class Grammar {
* @param string $table
* @return string
*/
p
ublic
function
compile_from
(
$table
)
p
rotected
function
compile_from
(
$table
)
{
return
'FROM '
.
$this
->
wrap
(
$table
);
}
...
...
@@ -90,7 +73,7 @@ class Grammar {
* @param array $joins
* @return string
*/
p
ublic
function
compile_joins
(
$joins
)
p
rotected
function
compile_joins
(
$joins
)
{
foreach
(
$joins
as
$join
)
{
...
...
@@ -108,28 +91,13 @@ class Grammar {
* @param array $wheres
* @return string
*/
p
ublic
function
compile_wheres
(
$wheres
)
p
rotected
function
compile_wheres
(
$wheres
)
{
$sql
=
array
(
'WHERE 1 = 1'
);
foreach
(
$wheres
as
$where
)
{
if
(
is_string
(
$where
))
{
$sql
[]
=
$where
;
}
elseif
(
$where
[
'type'
]
===
'where'
)
{
$sql
[]
=
$where
[
'connector'
]
.
' '
.
$this
->
compile_where
(
$where
);
}
elseif
(
$where
[
'type'
]
===
'where_in'
)
{
$sql
[]
=
$where
[
'connector'
]
.
' '
.
$this
->
compile_where_in
(
$where
);
}
elseif
(
$where
[
'type'
]
===
'where_null'
)
{
$sql
[]
=
$where
[
'connector'
]
.
' '
.
$this
->
compile_where_null
(
$where
);
}
$sql
[]
=
(
is_string
(
$where
))
?
$where
:
$where
[
'connector'
]
.
' '
.
$this
->
{
'compile_'
.
$where
[
'type'
]}(
$where
);
}
return
implode
(
' '
,
$sql
);
...
...
@@ -141,7 +109,7 @@ class Grammar {
* @param array $where
* @return string
*/
p
ublic
function
compile_where
(
$where
)
p
rotected
function
compile_where
(
$where
)
{
return
$this
->
wrap
(
$where
[
'column'
])
.
' '
.
$where
[
'operator'
]
.
' ?'
;
}
...
...
@@ -152,7 +120,7 @@ class Grammar {
* @param array $where
* @return string
*/
p
ublic
function
compile_where_in
(
$where
)
p
rotected
function
compile_where_in
(
$where
)
{
$operator
=
(
$where
[
'not'
])
?
'NOT IN'
:
'IN'
;
...
...
@@ -165,7 +133,7 @@ class Grammar {
* @param array $where
* @return string
*/
p
ublic
function
compile_where_null
(
$where
)
p
rotected
function
compile_where_null
(
$where
)
{
$operator
=
(
$where
[
'not'
])
?
'NOT NULL'
:
'NULL'
;
...
...
@@ -178,7 +146,7 @@ class Grammar {
* @param array $orderings
* @return string
*/
p
ublic
function
compile_orderings
(
$orderings
)
p
rotected
function
compile_orderings
(
$orderings
)
{
foreach
(
$orderings
as
$ordering
)
{
...
...
@@ -194,7 +162,7 @@ class Grammar {
* @param int $limit
* @return string
*/
p
ublic
function
compile_limit
(
$limit
)
p
rotected
function
compile_limit
(
$limit
)
{
return
'LIMIT '
.
$limit
;
}
...
...
@@ -205,7 +173,7 @@ class Grammar {
* @param int $offset
* @return string
*/
p
ublic
function
compile_offset
(
$offset
)
p
rotected
function
compile_offset
(
$offset
)
{
return
'OFFSET '
.
$offset
;
}
...
...
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