Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Commits
fcb8df3c
Commit
fcb8df3c
authored
Apr 4, 2010
by
Dries Buytaert
Browse files
Options
Downloads
Patches
Plain Diff
- Patch
#761316
by Crell: code simplification in query dispatchers.
parent
11af838d
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!7452
Issue #1797438. HTML5 validation is preventing form submit and not fully...
,
!789
Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
includes/database/database.inc
+32
-104
32 additions, 104 deletions
includes/database/database.inc
with
32 additions
and
104 deletions
includes/database/database.inc
+
32
−
104
View file @
fcb8df3c
...
...
@@ -212,56 +212,11 @@ abstract class DatabaseConnection extends PDO {
protected
$rollbackLogs
=
array
();
/**
*
The name of the Select class for this connec
tion.
*
Index of what driver-specific class to use for various opera
tion
s
.
*
* Normally this and the following class names would be static variables,
* but statics in methods are still global and shared by all instances.
*
* @var string
*/
protected
$selectClass
=
NULL
;
/**
* The name of the Delete class for this connection.
*
* @var string
*/
protected
$deleteClass
=
NULL
;
/**
* The name of the Truncate class for this connection.
*
* @var string
*/
protected
$truncateClass
=
NULL
;
/**
* The name of the Insert class for this connection.
*
* @var string
*/
protected
$insertClass
=
NULL
;
/**
* The name of the Merge class for this connection.
*
* @var string
*/
protected
$mergeClass
=
NULL
;
/**
* The name of the Update class for this connection.
*
* @var string
*/
protected
$updateClass
=
NULL
;
/**
* The name of the Transaction class for this connection.
*
* @var string
* @var array
*/
protected
$
transaction
Class
=
NULL
;
protected
$
driver
Class
es
=
array
()
;
/**
* The name of the Statement class for this connection.
...
...
@@ -652,6 +607,24 @@ protected function expandArguments(&$query, &$args) {
return
$modified
;
}
/**
* Gets the driver-specific override class if any for the specified class.
*
* @param string $class
* The class for which we want the potentially driver-specific class.
* @return string
* The name of the class that should be used for this driver.
*/
protected
function
getDriverClass
(
$class
)
{
if
(
empty
(
$this
->
driverClasses
[
$class
]))
{
$this
->
driverClasses
[
$class
]
=
$class
.
'_'
.
$this
->
driver
();
if
(
!
class_exists
(
$this
->
driverClasses
[
$class
]))
{
$this
->
driverClasses
[
$class
]
=
$class
;
}
}
return
$this
->
driverClasses
[
$class
];
}
/**
* Prepares and returns a SELECT query object with the specified ID.
*
...
...
@@ -672,17 +645,7 @@ protected function expandArguments(&$query, &$args) {
* @see SelectQuery
*/
public
function
select
(
$table
,
$alias
=
NULL
,
array
$options
=
array
())
{
if
(
empty
(
$this
->
selectClass
))
{
$this
->
selectClass
=
'SelectQuery_'
.
$this
->
driver
();
if
(
!
class_exists
(
$this
->
selectClass
))
{
$this
->
selectClass
=
'SelectQuery'
;
}
}
$class
=
$this
->
selectClass
;
// new is documented as the highest precedence operator so this will
// create a class named $class and pass the arguments into the constructor,
// instead of calling a function named $class with the arguments listed and
// then creating using the return value as the class name.
$class
=
$this
->
getDriverClass
(
'SelectQuery'
);
return
new
$class
(
$table
,
$alias
,
$this
,
$options
);
}
...
...
@@ -698,13 +661,7 @@ public function select($table, $alias = NULL, array $options = array()) {
* @see InsertQuery
*/
public
function
insert
(
$table
,
array
$options
=
array
())
{
if
(
empty
(
$this
->
insertClass
))
{
$this
->
insertClass
=
'InsertQuery_'
.
$this
->
driver
();
if
(
!
class_exists
(
$this
->
insertClass
))
{
$this
->
insertClass
=
'InsertQuery'
;
}
}
$class
=
$this
->
insertClass
;
$class
=
$this
->
getDriverClass
(
'InsertQuery'
);
return
new
$class
(
$this
,
$table
,
$options
);
}
...
...
@@ -720,13 +677,7 @@ public function insert($table, array $options = array()) {
* @see MergeQuery
*/
public
function
merge
(
$table
,
array
$options
=
array
())
{
if
(
empty
(
$this
->
mergeClass
))
{
$this
->
mergeClass
=
'MergeQuery_'
.
$this
->
driver
();
if
(
!
class_exists
(
$this
->
mergeClass
))
{
$this
->
mergeClass
=
'MergeQuery'
;
}
}
$class
=
$this
->
mergeClass
;
$class
=
$this
->
getDriverClass
(
'MergeQuery'
);
return
new
$class
(
$this
,
$table
,
$options
);
}
...
...
@@ -743,13 +694,7 @@ public function merge($table, array $options = array()) {
* @see UpdateQuery
*/
public
function
update
(
$table
,
array
$options
=
array
())
{
if
(
empty
(
$this
->
updateClass
))
{
$this
->
updateClass
=
'UpdateQuery_'
.
$this
->
driver
();
if
(
!
class_exists
(
$this
->
updateClass
))
{
$this
->
updateClass
=
'UpdateQuery'
;
}
}
$class
=
$this
->
updateClass
;
$class
=
$this
->
getDriverClass
(
'UpdateQuery'
);
return
new
$class
(
$this
,
$table
,
$options
);
}
...
...
@@ -765,13 +710,7 @@ public function update($table, array $options = array()) {
* @see DeleteQuery
*/
public
function
delete
(
$table
,
array
$options
=
array
())
{
if
(
empty
(
$this
->
deleteClass
))
{
$this
->
deleteClass
=
'DeleteQuery_'
.
$this
->
driver
();
if
(
!
class_exists
(
$this
->
deleteClass
))
{
$this
->
deleteClass
=
'DeleteQuery'
;
}
}
$class
=
$this
->
deleteClass
;
$class
=
$this
->
getDriverClass
(
'DeleteQuery'
);
return
new
$class
(
$this
,
$table
,
$options
);
}
...
...
@@ -787,13 +726,7 @@ public function delete($table, array $options = array()) {
* @see TruncateQuery
*/
public
function
truncate
(
$table
,
array
$options
=
array
())
{
if
(
empty
(
$this
->
truncateClass
))
{
$this
->
truncateClass
=
'TruncateQuery_'
.
$this
->
driver
();
if
(
!
class_exists
(
$this
->
truncateClass
))
{
$this
->
truncateClass
=
'TruncateQuery'
;
}
}
$class
=
$this
->
truncateClass
;
$class
=
$this
->
getDriverClass
(
'TruncateQuery'
);
return
new
$class
(
$this
,
$table
,
$options
);
}
...
...
@@ -807,8 +740,8 @@ public function truncate($table, array $options = array()) {
*/
public
function
schema
()
{
if
(
empty
(
$this
->
schema
))
{
$class
_type
=
'DatabaseSchema_'
.
$this
->
driver
(
);
$this
->
schema
=
new
$class
_type
(
$this
);
$class
=
$this
->
getDriverClass
(
'DatabaseSchema'
);
$this
->
schema
=
new
$class
(
$this
);
}
return
$this
->
schema
;
}
...
...
@@ -882,13 +815,8 @@ public function transactionDepth() {
* @see DatabaseTransaction
*/
public
function
startTransaction
(
$name
=
''
)
{
if
(
empty
(
$this
->
transactionClass
))
{
$this
->
transactionClass
=
'DatabaseTransaction_'
.
$this
->
driver
();
if
(
!
class_exists
(
$this
->
transactionClass
))
{
$this
->
transactionClass
=
'DatabaseTransaction'
;
}
}
return
new
$this
->
transactionClass
(
$this
,
$name
);
$class
=
$this
->
getDriverClass
(
'DatabaseTransaction'
);
return
new
$class
(
$this
,
$name
);
}
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment