Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
221
Merge Requests
221
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
bd2527a4
Commit
bd2527a4
authored
Nov 21, 2006
by
Dries
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Patch
#98059
by chx: trying to get the never-ending regex mess right.
parent
e66c520a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
3 additions
and
3 deletions
+3
-3
includes/database.mysql.inc
includes/database.mysql.inc
+1
-1
includes/database.mysqli.inc
includes/database.mysqli.inc
+1
-1
includes/database.pgsql.inc
includes/database.pgsql.inc
+1
-1
No files found.
includes/database.mysql.inc
View file @
bd2527a4
...
...
@@ -431,7 +431,7 @@ function db_table_exists($table) {
function
db_distinct_field
(
$table
,
$field
,
$query
)
{
$field_to_select
=
'DISTINCT('
.
$table
.
'.'
.
$field
.
')'
;
// (?<!text) is a negative look-behind (no need to rewrite queries that already use DISTINCT).
return
preg_replace
(
'/(SELECT.*)(
'
.
$table
.
'\.)?(?<!DISTINCT\()(?<!DISTINCT\('
.
$table
.
'\.)'
.
$field
.
'(.*FROM )/AUsi'
,
'\1'
.
$field_to_select
.
'\3
'
,
$query
);
return
preg_replace
(
'/(SELECT.*)(
?:'
.
$table
.
'\.|\s)(?<!DISTINCT\()(?<!DISTINCT\('
.
$table
.
'\.)'
.
$field
.
'(.*FROM )/AUsi'
,
'\1 '
.
$field_to_select
.
'\2
'
,
$query
);
}
/**
...
...
includes/database.mysqli.inc
View file @
bd2527a4
...
...
@@ -416,7 +416,7 @@ function db_table_exists($table) {
function
db_distinct_field
(
$table
,
$field
,
$query
)
{
$field_to_select
=
'DISTINCT('
.
$table
.
'.'
.
$field
.
')'
;
// (?<!text) is a negative look-behind (no need to rewrite queries that already use DISTINCT).
return
preg_replace
(
'/(SELECT.*)(
'
.
$table
.
'\.)?(?<!DISTINCT\()(?<!DISTINCT\('
.
$table
.
'\.)'
.
$field
.
'(.*FROM )/AUsi'
,
'\1'
.
$field_to_select
.
'\3
'
,
$query
);
return
preg_replace
(
'/(SELECT.*)(
?:'
.
$table
.
'\.|\s)(?<!DISTINCT\()(?<!DISTINCT\('
.
$table
.
'\.)'
.
$field
.
'(.*FROM )/AUsi'
,
'\1 '
.
$field_to_select
.
'\2
'
,
$query
);
}
/**
...
...
includes/database.pgsql.inc
View file @
bd2527a4
...
...
@@ -414,7 +414,7 @@ function db_check_setup() {
function
db_distinct_field
(
$table
,
$field
,
$query
)
{
$field_to_select
=
'DISTINCT ON ('
.
$table
.
'.'
.
$field
.
")
$table
.
$field
"
;
// (?<!text) is a negative look-behind (no need to rewrite queries that already use DISTINCT).
$query
=
preg_replace
(
'/(SELECT.*)(
'
.
$table
.
'\.)?(?<!DISTINCT\()(?<!DISTINCT\('
.
$table
.
'\.)'
.
$field
.
'(.*FROM )/AUsi'
,
'\1'
.
$field_to_select
.
'\3
'
,
$query
);
$query
=
preg_replace
(
'/(SELECT.*)(
?:'
.
$table
.
'\.|\s)(?<!DISTINCT\()(?<!DISTINCT\('
.
$table
.
'\.)'
.
$field
.
'(.*FROM )/AUsi'
,
'\1 '
.
$field_to_select
.
'\2
'
,
$query
);
$query
=
preg_replace
(
'/(ORDER BY )(?!'
.
$table
.
'\.'
.
$field
.
')/'
,
'\1'
.
"
$table
.
$field
, "
,
$query
);
return
$query
;
}
...
...
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