Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
Tomáš Trávníček
doctrine-dbal
Commits
521a7b80
Commit
521a7b80
authored
Jan 22, 2013
by
Norbert Orzechowicz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated regular expressions in doModifyLimitQuery
parent
88c1975d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
9 deletions
+7
-9
SQLServerPlatform.php
lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php
+7
-9
No files found.
lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php
View file @
521a7b80
...
...
@@ -674,27 +674,25 @@ class SQLServerPlatform extends AbstractPlatform
if
(
$limit
>
0
)
{
$orderby
=
stristr
(
$query
,
'ORDER BY'
);
//Remove ORDER BY from $query
$query
=
preg_replace
(
'/\s
*ORDER\s*BY
([^\)]*)/'
,
''
,
$query
);
$query
=
preg_replace
(
'/\s
+ORDER\s+BY\s+
([^\)]*)/'
,
''
,
$query
);
$over
=
'ORDER BY'
;
if
(
!
$orderby
)
{
$over
.=
' (SELECT 0)'
;
}
else
{
//Clear ORDER BY
$orderby
=
preg_replace
(
'/ORDER
BY\s?
([^\)]*)(.*)/'
,
'$1'
,
$orderby
);
$orderby
=
preg_replace
(
'/ORDER
\s+BY\s+
([^\)]*)(.*)/'
,
'$1'
,
$orderby
);
$orderbyParts
=
explode
(
','
,
$orderby
);
$orderbyColumns
=
array
();
//Split ORDER BY into parts
foreach
(
$orderbyParts
as
&
$part
)
{
$part
=
trim
(
$part
);
if
(
preg_match
(
'/(
[^\s]*
\.)?([^\.\s]*)\s*(ASC|DESC)?/i'
,
$part
,
$matches
))
{
if
(
preg_match
(
'/(
([^\s]*)
\.)?([^\.\s]*)\s*(ASC|DESC)?/i'
,
$part
,
$matches
))
{
$orderbyColumns
[]
=
array
(
'table'
=>
empty
(
$matches
[
1
])
?
'[^\.\s]*'
:
rtrim
(
$matches
[
1
],
'.'
),
'column'
=>
$matches
[
2
],
'sort'
=>
isset
(
$matches
[
3
])
?
$matches
[
3
]
:
null
'table'
=>
empty
(
$matches
[
2
])
?
'[^\.\s]*'
:
$matches
[
2
],
'column'
=>
$matches
[
3
],
'sort'
=>
isset
(
$matches
[
4
])
?
$matches
[
4
]
:
null
);
}
}
...
...
@@ -702,7 +700,7 @@ class SQLServerPlatform extends AbstractPlatform
//Find alias for each colum used in ORDER BY
if
(
count
(
$orderbyColumns
))
{
foreach
(
$orderbyColumns
as
$column
)
{
if
(
preg_match
(
'/'
.
$column
[
'table'
]
.
'\.('
.
$column
[
'column'
]
.
')\s
?(AS)?\s?
([^,\s\)]*)/i'
,
$query
,
$matches
))
{
if
(
preg_match
(
'/'
.
$column
[
'table'
]
.
'\.('
.
$column
[
'column'
]
.
')\s
*(AS)?\s*
([^,\s\)]*)/i'
,
$query
,
$matches
))
{
$over
.=
' '
.
$matches
[
3
];
$over
.=
isset
(
$column
[
'sort'
])
?
' '
.
$column
[
'sort'
]
.
','
:
','
;
}
else
{
...
...
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