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
9d4d6e52
Commit
9d4d6e52
authored
Aug 14, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor database structure... moved db\manager back to system\db.php
parent
21a6040a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
15 additions
and
18 deletions
+15
-18
aliases.php
application/config/aliases.php
+1
-1
db.php
system/db.php
+8
-10
model.php
system/db/eloquent/model.php
+4
-4
db.php
system/session/db.php
+1
-2
validator.php
system/validator.php
+1
-1
No files found.
application/config/aliases.php
View file @
9d4d6e52
...
...
@@ -26,7 +26,7 @@ return array(
'Cookie'
=>
'System\\Cookie'
,
'Crypt'
=>
'System\\Crypt'
,
'Date'
=>
'System\\Date'
,
'DB'
=>
'System\\DB
\\Manager
'
,
'DB'
=>
'System\\DB'
,
'Eloquent'
=>
'System\\DB\\Eloquent\\Model'
,
'File'
=>
'System\\File'
,
'Form'
=>
'System\\Form'
,
...
...
system/db
/manager
.php
→
system/db.php
View file @
9d4d6e52
<?php
namespace
System
\DB
;
<?php
namespace
System
;
use
System\Config
;
class
Manager
{
class
DB
{
/**
* The established database connections.
...
...
@@ -17,8 +15,8 @@ class Manager {
*
* Note: Database connections are managed as singletons.
*
* @param string $connection
* @return Connection
* @param string
$connection
* @return
DB\
Connection
*/
public
static
function
connection
(
$connection
=
null
)
{
...
...
@@ -34,7 +32,7 @@ class Manager {
throw
new
\Exception
(
"Database connection [
$connection
] is not defined."
);
}
static
::
$connections
[
$connection
]
=
new
Connection
(
$connection
,
(
object
)
$config
,
new
Connector
);
static
::
$connections
[
$connection
]
=
new
DB\Connection
(
$connection
,
(
object
)
$config
,
new
DB\
Connector
);
}
return
static
::
$connections
[
$connection
];
...
...
@@ -43,9 +41,9 @@ class Manager {
/**
* Begin a fluent query against a table.
*
* @param string $table
* @param string $connection
* @return Query
* @param string
$table
* @param string
$connection
* @return
DB\
Query
*/
public
static
function
table
(
$table
,
$connection
=
null
)
{
...
...
system/db/eloquent/model.php
View file @
9d4d6e52
<?php
namespace
System\DB\Eloquent
;
use
System\DB
;
use
System\Str
;
use
System\Config
;
use
System\Inflector
;
use
System\Paginator
;
use
System\DB\Manager
;
abstract
class
Model
{
...
...
@@ -135,7 +135,7 @@ abstract class Model {
// Since this method is only used for instantiating models for querying
// purposes, we will go ahead and set the Query instance on the model.
$model
->
query
=
Manager
::
connection
(
static
::
$connection
)
->
table
(
static
::
table
(
$class
));
$model
->
query
=
DB
::
connection
(
static
::
$connection
)
->
table
(
static
::
table
(
$class
));
return
$model
;
}
...
...
@@ -367,7 +367,7 @@ abstract class Model {
// Since the model was instantiated using "new", a query instance has not been set.
// Only models being used for querying have their query instances set by default.
$this
->
query
=
Manager
::
connection
(
static
::
$connection
)
->
table
(
static
::
table
(
$model
));
$this
->
query
=
DB
::
connection
(
static
::
$connection
)
->
table
(
static
::
table
(
$model
));
if
(
property_exists
(
$model
,
'timestamps'
)
and
$model
::
$timestamps
)
{
...
...
@@ -416,7 +416,7 @@ abstract class Model {
// delete statement to the query instance.
if
(
!
$this
->
exists
)
return
$this
->
query
->
delete
();
return
Manager
::
connection
(
static
::
$connection
)
->
table
(
static
::
table
(
get_class
(
$this
)))
->
delete
(
$this
->
id
);
return
DB
::
connection
(
static
::
$connection
)
->
table
(
static
::
table
(
get_class
(
$this
)))
->
delete
(
$this
->
id
);
}
/**
...
...
system/session/db.php
View file @
9d4d6e52
<?php
namespace
System\Session
;
use
System\Config
;
use
System\DB\Manager
;
class
DB
implements
Driver
,
Sweeper
{
...
...
@@ -71,7 +70,7 @@ class DB implements Driver, Sweeper {
*/
private
function
table
()
{
return
Manager
::
connection
()
->
table
(
Config
::
get
(
'session.table'
));
return
\System\DB
::
connection
()
->
table
(
Config
::
get
(
'session.table'
));
}
}
\ No newline at end of file
system/validator.php
View file @
9d4d6e52
...
...
@@ -302,7 +302,7 @@ class Validator {
{
if
(
!
isset
(
$parameters
[
1
]))
$parameters
[
1
]
=
$attribute
;
return
DB
\Manager
::
connection
()
->
table
(
$parameters
[
0
])
->
where
(
$parameters
[
1
],
'='
,
$this
->
attributes
[
$attribute
])
->
count
()
==
0
;
return
DB
::
connection
()
->
table
(
$parameters
[
0
])
->
where
(
$parameters
[
1
],
'='
,
$this
->
attributes
[
$attribute
])
->
count
()
==
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