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
3e874867
Commit
3e874867
authored
Sep 05, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
database refactoring for dependency injection and other general refactoring.
parent
c2f5e7ee
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
18 deletions
+30
-18
container.php
laravel/config/container.php
+1
-1
connection.php
laravel/database/connection.php
+17
-5
manager.php
laravel/database/manager.php
+6
-6
query.php
laravel/database/query.php
+2
-2
factory.php
laravel/database/query/factory.php
+4
-4
No files found.
laravel/config/container.php
View file @
3e874867
...
...
@@ -45,7 +45,7 @@ return array(
{
$config
=
$container
->
resolve
(
'laravel.config'
);
return
new
Database\Manager
(
$config
->
get
(
'database.connections'
),
$config
->
get
(
'database.default'
));
return
new
Database\Manager
(
new
Database\Connector\Factory
,
$config
->
get
(
'database.connections'
),
$config
->
get
(
'database.default'
));
}),
...
...
laravel/database/connection.php
View file @
3e874867
...
...
@@ -40,15 +40,19 @@ class Connection {
/**
* Create a new Connection instance.
*
* @param string $name
* @param array $config
* @param Connector $connector
* @param Connector $connector
* @param Query\Factory $factory
* @param Compiler\Factory $compiler
* @param string $name
* @param array $config
* @return void
*/
public
function
__construct
(
$name
,
$config
,
Connector
$connector
)
public
function
__construct
(
Connector
$connector
,
Query\Factory
$query
,
Query\Compiler\Factory
$compiler
,
$name
,
$config
)
{
$this
->
name
=
$name
;
$this
->
query
=
$query
;
$this
->
config
=
$config
;
$this
->
compiler
=
$compiler
;
$this
->
connector
=
$connector
;
}
...
...
@@ -152,7 +156,7 @@ class Connection {
*/
public
function
table
(
$table
)
{
return
Query\Factory
::
make
(
$table
,
$this
,
Query\Compiler\Factory
::
make
(
$this
)
);
return
$this
->
query
->
make
(
$this
,
$this
->
compiler
->
make
(
$this
),
$table
);
}
/**
...
...
@@ -167,4 +171,12 @@ class Connection {
return
$this
->
pdo
->
getAttribute
(
\PDO
::
ATTR_DRIVER_NAME
);
}
/**
* Magic Method for dynamically beginning queries on database tables.
*/
public
function
__call
(
$method
,
$parameters
)
{
return
$this
->
table
(
$method
);
}
}
\ No newline at end of file
laravel/database/manager.php
View file @
3e874867
...
...
@@ -22,7 +22,7 @@ class Manager {
*
* @var Connector\Factory
*/
protected
$
factory
;
protected
$
connector
;
/**
* The database connection configurations.
...
...
@@ -41,16 +41,16 @@ class Manager {
/**
* Create a new database manager instance.
*
* @param Connector\Factory $
factory
* @param Connector\Factory $
connector
* @param array $config
* @param string $default
* @return void
*/
public
function
__construct
(
Connector\Factory
$
factory
,
$config
,
$default
)
public
function
__construct
(
Connector\Factory
$
connector
,
$config
,
$default
)
{
$this
->
config
=
$config
;
$this
->
factory
=
$factory
;
$this
->
default
=
$default
;
$this
->
connector
=
$connector
;
}
/**
...
...
@@ -73,9 +73,9 @@ class Manager {
throw
new
\Exception
(
"Database connection [
$connection
] is not defined."
);
}
$connector
=
$this
->
factory
->
make
(
$this
->
config
[
$connection
]
);
list
(
$connector
,
$query
,
$compiler
)
=
array
(
$this
->
connector
->
make
(
$this
->
config
[
$connection
]),
new
Query\Factory
,
new
Query\Compiler\Factory
);
static
::
$connections
[
$connection
]
=
new
Connection
(
$connection
,
$this
->
config
[
$connection
],
$connector
);
$this
->
connections
[
$connection
]
=
new
Connection
(
$connector
,
$query
,
$compiler
,
$connection
,
$this
->
config
[
$connection
]
);
}
return
$this
->
connections
[
$connection
];
...
...
laravel/database/query.php
View file @
3e874867
...
...
@@ -90,12 +90,12 @@ class Query {
/**
* Create a new query instance.
*
* @param string $table
* @param Connection $connection
* @param Compiler $compiler
* @param string $table
* @return void
*/
public
function
__construct
(
$table
,
Connection
$connection
,
Query\Compiler
$compiler
)
public
function
__construct
(
Connection
$connection
,
Query\Compiler
$compiler
,
$table
)
{
$this
->
table
=
$table
;
$this
->
compiler
=
$compiler
;
...
...
laravel/database/query/factory.php
View file @
3e874867
...
...
@@ -8,20 +8,20 @@ class Factory {
/**
* Create a new query instance based on the connection driver.
*
* @param string $table
* @param Connection $connection
* @param Compiler $compiler
* @param string $table
* @return Query
*/
public
static
function
make
(
$table
,
Connection
$connection
,
Compiler
$compiler
)
public
function
make
(
Connection
$connection
,
Compiler
$compiler
,
$table
)
{
switch
(
$connection
->
driver
())
{
case
'pgsql'
:
return
new
Postgres
(
$
table
,
$connection
,
$compiler
);
return
new
Postgres
(
$
connection
,
$compiler
,
$table
);
default
:
return
new
Query
(
$
table
,
$connection
,
$compiler
);
return
new
Query
(
$
connection
,
$compiler
,
$table
);
}
}
...
...
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