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
479b3f67
Commit
479b3f67
authored
Feb 14, 2012
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleaning up various codes.
parent
f27ec7ab
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
54 additions
and
17 deletions
+54
-17
sqlite.php
laravel/database/connectors/sqlite.php
+1
-2
grammar.php
laravel/database/grammar.php
+1
-2
query.php
laravel/database/query.php
+3
-3
schema.php
laravel/database/schema.php
+49
-7
mysql.php
laravel/database/schema/grammars/mysql.php
+0
-3
No files found.
laravel/database/connectors/sqlite.php
View file @
479b3f67
...
@@ -14,8 +14,7 @@ class SQLite extends Connector {
...
@@ -14,8 +14,7 @@ class SQLite extends Connector {
// SQLite provides supported for "in-memory" databases, which exist only for the
// SQLite provides supported for "in-memory" databases, which exist only for the
// lifetime of the request. Any given in-memory database may only have one PDO
// lifetime of the request. Any given in-memory database may only have one PDO
// connection open to it at a time. Generally, these databases are used for
// connection open to it at a time. These are usually for testing.
// testing and development purposes, not in production scenarios.
if
(
$config
[
'database'
]
==
':memory:'
)
if
(
$config
[
'database'
]
==
':memory:'
)
{
{
return
new
PDO
(
'sqlite::memory:'
,
null
,
null
,
$options
);
return
new
PDO
(
'sqlite::memory:'
,
null
,
null
,
$options
);
...
...
laravel/database/grammar.php
View file @
479b3f67
...
@@ -63,8 +63,7 @@ abstract class Grammar {
...
@@ -63,8 +63,7 @@ abstract class Grammar {
// If the value being wrapped contains a column alias, we need to
// If the value being wrapped contains a column alias, we need to
// wrap it a little differently as each segment must be wrapped
// wrap it a little differently as each segment must be wrapped
// and not the entire string. We'll split the value on the "as"
// and not the entire string.
// joiner to extract the column and the alias.
if
(
strpos
(
strtolower
(
$value
),
' as '
)
!==
false
)
if
(
strpos
(
strtolower
(
$value
),
' as '
)
!==
false
)
{
{
$segments
=
explode
(
' '
,
$value
);
$segments
=
explode
(
' '
,
$value
);
...
...
laravel/database/query.php
View file @
479b3f67
...
@@ -401,11 +401,11 @@ class Query {
...
@@ -401,11 +401,11 @@ class Query {
// will allow the developer to have a fresh query.
// will allow the developer to have a fresh query.
$query
=
new
Query
(
$this
->
connection
,
$this
->
grammar
,
$this
->
from
);
$query
=
new
Query
(
$this
->
connection
,
$this
->
grammar
,
$this
->
from
);
// Once the callback has been run on the query, we will store the
// nested query instance on the where clause array so that it's
// passed to the query grammar.
call_user_func
(
$callback
,
$query
);
call_user_func
(
$callback
,
$query
);
// Once the callback has been run on the query, we will store the
// nested query instance on the where clause array so that it's
// passed to the query's query grammar instance.
$this
->
wheres
[]
=
compact
(
'type'
,
'query'
,
'connector'
);
$this
->
wheres
[]
=
compact
(
'type'
,
'query'
,
'connector'
);
$this
->
bindings
=
array_merge
(
$this
->
bindings
,
$query
->
bindings
);
$this
->
bindings
=
array_merge
(
$this
->
bindings
,
$query
->
bindings
);
...
...
laravel/database/schema.php
View file @
479b3f67
...
@@ -16,7 +16,44 @@ class Schema {
...
@@ -16,7 +16,44 @@ class Schema {
{
{
call_user_func
(
$callback
,
$table
=
new
Schema\Table
(
$table
));
call_user_func
(
$callback
,
$table
=
new
Schema\Table
(
$table
));
static
::
implications
(
$table
);
return
static
::
execute
(
$table
);
}
/**
* Create a new database table schema.
*
* @param string $table
* @param Closure $callback
* @return void
*/
public
static
function
create
(
$table
,
$callback
)
{
$table
=
new
Schema\Table
(
$table
);
// To indicate that the table is new and needs to be created, we'll run
// the "create" command on the table instance. This tells schema it is
// not simply a column modification operation.
$table
->
create
();
call_user_func
(
$callback
,
$table
);
return
static
::
execute
(
$table
);
}
/**
* Drop a database table from the schema.
*
* @param string $table
* @return void
*/
public
static
function
drop
(
$table
)
{
$table
=
new
Schema\Table
(
$table
);
// To indicate that the table needs to be dropped, we will run the
// "drop" command on the table instance and pass the instance to
// the execute method as calling a Closure isn't needed.
$table
->
drop
();
return
static
::
execute
(
$table
);
return
static
::
execute
(
$table
);
}
}
...
@@ -29,22 +66,27 @@ class Schema {
...
@@ -29,22 +66,27 @@ class Schema {
*/
*/
public
static
function
execute
(
$table
)
public
static
function
execute
(
$table
)
{
{
// The implications method is responsible for finding any fluently
// defined indexes on the schema table and adding the explicit
// commands that are needed to tbe schema instance.
static
::
implications
(
$table
);
foreach
(
$table
->
commands
as
$command
)
foreach
(
$table
->
commands
as
$command
)
{
{
$connection
=
DB
::
connection
(
$table
->
connection
);
$connection
=
DB
::
connection
(
$table
->
connection
);
$grammar
=
static
::
grammar
(
$connection
);
$grammar
=
static
::
grammar
(
$connection
);
// Each grammar has a function that corresponds to the command type and
is for
// Each grammar has a function that corresponds to the command type and
//
building that command's SQL. This lets the SQL generation stay granular
//
is for building that command's SQL. This lets the SQL syntax builds
//
and flexible
across various database systems.
//
stay granular
across various database systems.
if
(
method_exists
(
$grammar
,
$method
=
$command
->
type
))
if
(
method_exists
(
$grammar
,
$method
=
$command
->
type
))
{
{
$statements
=
$grammar
->
$method
(
$table
,
$command
);
$statements
=
$grammar
->
$method
(
$table
,
$command
);
// Once we have the statements, we will cast them to an array even
though
// Once we have the statements, we will cast them to an array even
//
not all of the commands return an array just in case the command
//
though not all of the commands return an array just in case it
// needs multiple queries to complete
its database work
.
// needs multiple queries to complete.
foreach
((
array
)
$statements
as
$statement
)
foreach
((
array
)
$statements
as
$statement
)
{
{
$connection
->
statement
(
$statement
);
$connection
->
statement
(
$statement
);
...
...
laravel/database/schema/grammars/mysql.php
View file @
479b3f67
...
@@ -28,9 +28,6 @@ class MySQL extends Grammar {
...
@@ -28,9 +28,6 @@ class MySQL extends Grammar {
// of the table as they're added in separate commands.
// of the table as they're added in separate commands.
$sql
=
'CREATE TABLE '
.
$this
->
wrap
(
$table
)
.
' ('
.
$columns
.
')'
;
$sql
=
'CREATE TABLE '
.
$this
->
wrap
(
$table
)
.
' ('
.
$columns
.
')'
;
// MySQL supports various "engines" for database tables. If an engine was
// specified by the developer, we will set it after adding the columns
// the table creation statement the schema.
if
(
!
is_null
(
$table
->
engine
))
if
(
!
is_null
(
$table
->
engine
))
{
{
$sql
.=
' ENGINE = '
.
$table
->
engine
;
$sql
.=
' ENGINE = '
.
$table
->
engine
;
...
...
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