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
Show 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(
...
@@ -26,7 +26,7 @@ return array(
'Cookie'
=>
'System\\Cookie'
,
'Cookie'
=>
'System\\Cookie'
,
'Crypt'
=>
'System\\Crypt'
,
'Crypt'
=>
'System\\Crypt'
,
'Date'
=>
'System\\Date'
,
'Date'
=>
'System\\Date'
,
'DB'
=>
'System\\DB
\\Manager
'
,
'DB'
=>
'System\\DB'
,
'Eloquent'
=>
'System\\DB\\Eloquent\\Model'
,
'Eloquent'
=>
'System\\DB\\Eloquent\\Model'
,
'File'
=>
'System\\File'
,
'File'
=>
'System\\File'
,
'Form'
=>
'System\\Form'
,
'Form'
=>
'System\\Form'
,
...
...
system/db
/manager
.php
→
system/db.php
View file @
9d4d6e52
<?php
namespace
System
\DB
;
<?php
namespace
System
;
use
System\Config
;
class
DB
{
class
Manager
{
/**
/**
* The established database connections.
* The established database connections.
...
@@ -18,7 +16,7 @@ class Manager {
...
@@ -18,7 +16,7 @@ class Manager {
* Note: Database connections are managed as singletons.
* Note: Database connections are managed as singletons.
*
*
* @param string $connection
* @param string $connection
* @return Connection
* @return
DB\
Connection
*/
*/
public
static
function
connection
(
$connection
=
null
)
public
static
function
connection
(
$connection
=
null
)
{
{
...
@@ -34,7 +32,7 @@ class Manager {
...
@@ -34,7 +32,7 @@ class Manager {
throw
new
\Exception
(
"Database connection [
$connection
] is not defined."
);
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
];
return
static
::
$connections
[
$connection
];
...
@@ -45,7 +43,7 @@ class Manager {
...
@@ -45,7 +43,7 @@ class Manager {
*
*
* @param string $table
* @param string $table
* @param string $connection
* @param string $connection
* @return Query
* @return
DB\
Query
*/
*/
public
static
function
table
(
$table
,
$connection
=
null
)
public
static
function
table
(
$table
,
$connection
=
null
)
{
{
...
...
system/db/eloquent/model.php
View file @
9d4d6e52
<?php
namespace
System\DB\Eloquent
;
<?php
namespace
System\DB\Eloquent
;
use
System\DB
;
use
System\Str
;
use
System\Str
;
use
System\Config
;
use
System\Config
;
use
System\Inflector
;
use
System\Inflector
;
use
System\Paginator
;
use
System\Paginator
;
use
System\DB\Manager
;
abstract
class
Model
{
abstract
class
Model
{
...
@@ -135,7 +135,7 @@ abstract class Model {
...
@@ -135,7 +135,7 @@ abstract class Model {
// Since this method is only used for instantiating models for querying
// Since this method is only used for instantiating models for querying
// purposes, we will go ahead and set the Query instance on the model.
// 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
;
return
$model
;
}
}
...
@@ -367,7 +367,7 @@ abstract class Model {
...
@@ -367,7 +367,7 @@ abstract class Model {
// Since the model was instantiated using "new", a query instance has not been set.
// 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.
// 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
)
if
(
property_exists
(
$model
,
'timestamps'
)
and
$model
::
$timestamps
)
{
{
...
@@ -416,7 +416,7 @@ abstract class Model {
...
@@ -416,7 +416,7 @@ abstract class Model {
// delete statement to the query instance.
// delete statement to the query instance.
if
(
!
$this
->
exists
)
return
$this
->
query
->
delete
();
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
;
<?php
namespace
System\Session
;
use
System\Config
;
use
System\Config
;
use
System\DB\Manager
;
class
DB
implements
Driver
,
Sweeper
{
class
DB
implements
Driver
,
Sweeper
{
...
@@ -71,7 +70,7 @@ class DB implements Driver, Sweeper {
...
@@ -71,7 +70,7 @@ class DB implements Driver, Sweeper {
*/
*/
private
function
table
()
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 {
...
@@ -302,7 +302,7 @@ class Validator {
{
{
if
(
!
isset
(
$parameters
[
1
]))
$parameters
[
1
]
=
$attribute
;
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