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
11111bd7
Commit
11111bd7
authored
Jun 12, 2013
by
Kinn Coelho Julião
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Quoting Table name
Quoting table name to avoid errors with: SELECT * FROM order;
parent
226dba89
Changes
2
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
45 deletions
+54
-45
QueryBuilder.php
lib/Doctrine/DBAL/Query/QueryBuilder.php
+4
-4
QueryBuilderTest.php
tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php
+50
-41
No files found.
lib/Doctrine/DBAL/Query/QueryBuilder.php
View file @
11111bd7
...
@@ -951,7 +951,7 @@ class QueryBuilder
...
@@ -951,7 +951,7 @@ class QueryBuilder
// Loop through all FROM clauses
// Loop through all FROM clauses
foreach
(
$this
->
sqlParts
[
'from'
]
as
$from
)
{
foreach
(
$this
->
sqlParts
[
'from'
]
as
$from
)
{
$knownAliases
[
$from
[
'alias'
]]
=
true
;
$knownAliases
[
$from
[
'alias'
]]
=
true
;
$fromClause
=
$
from
[
'table'
]
.
' '
.
$from
[
'alias'
]
$fromClause
=
$
this
->
connection
->
quoteIdentifier
(
$from
[
'table'
])
.
' '
.
$from
[
'alias'
]
.
$this
->
getSQLForJoins
(
$from
[
'alias'
],
$knownAliases
);
.
$this
->
getSQLForJoins
(
$from
[
'alias'
],
$knownAliases
);
$fromClauses
[
$from
[
'alias'
]]
=
$fromClause
;
$fromClauses
[
$from
[
'alias'
]]
=
$fromClause
;
...
@@ -981,7 +981,7 @@ class QueryBuilder
...
@@ -981,7 +981,7 @@ class QueryBuilder
*/
*/
private
function
getSQLForUpdate
()
private
function
getSQLForUpdate
()
{
{
$table
=
$this
->
sqlParts
[
'from'
][
'table'
]
.
(
$this
->
sqlParts
[
'from'
][
'alias'
]
?
' '
.
$this
->
sqlParts
[
'from'
][
'alias'
]
:
''
);
$table
=
$this
->
connection
->
quoteIdentifier
(
$this
->
sqlParts
[
'from'
][
'table'
])
.
(
$this
->
sqlParts
[
'from'
][
'alias'
]
?
' '
.
$this
->
sqlParts
[
'from'
][
'alias'
]
:
''
);
$query
=
'UPDATE '
.
$table
$query
=
'UPDATE '
.
$table
.
' SET '
.
implode
(
", "
,
$this
->
sqlParts
[
'set'
])
.
' SET '
.
implode
(
", "
,
$this
->
sqlParts
[
'set'
])
.
(
$this
->
sqlParts
[
'where'
]
!==
null
?
' WHERE '
.
((
string
)
$this
->
sqlParts
[
'where'
])
:
''
);
.
(
$this
->
sqlParts
[
'where'
]
!==
null
?
' WHERE '
.
((
string
)
$this
->
sqlParts
[
'where'
])
:
''
);
...
@@ -996,7 +996,7 @@ class QueryBuilder
...
@@ -996,7 +996,7 @@ class QueryBuilder
*/
*/
private
function
getSQLForDelete
()
private
function
getSQLForDelete
()
{
{
$table
=
$this
->
sqlParts
[
'from'
][
'table'
]
.
(
$this
->
sqlParts
[
'from'
][
'alias'
]
?
' '
.
$this
->
sqlParts
[
'from'
][
'alias'
]
:
''
);
$table
=
$this
->
connection
->
quoteIdentifier
(
$this
->
sqlParts
[
'from'
][
'table'
])
.
(
$this
->
sqlParts
[
'from'
][
'alias'
]
?
' '
.
$this
->
sqlParts
[
'from'
][
'alias'
]
:
''
);
$query
=
'DELETE FROM '
.
$table
.
(
$this
->
sqlParts
[
'where'
]
!==
null
?
' WHERE '
.
((
string
)
$this
->
sqlParts
[
'where'
])
:
''
);
$query
=
'DELETE FROM '
.
$table
.
(
$this
->
sqlParts
[
'where'
]
!==
null
?
' WHERE '
.
((
string
)
$this
->
sqlParts
[
'where'
])
:
''
);
return
$query
;
return
$query
;
...
@@ -1086,7 +1086,7 @@ class QueryBuilder
...
@@ -1086,7 +1086,7 @@ class QueryBuilder
if
(
isset
(
$this
->
sqlParts
[
'join'
][
$fromAlias
]))
{
if
(
isset
(
$this
->
sqlParts
[
'join'
][
$fromAlias
]))
{
foreach
(
$this
->
sqlParts
[
'join'
][
$fromAlias
]
as
$join
)
{
foreach
(
$this
->
sqlParts
[
'join'
][
$fromAlias
]
as
$join
)
{
$sql
.=
' '
.
strtoupper
(
$join
[
'joinType'
])
$sql
.=
' '
.
strtoupper
(
$join
[
'joinType'
])
.
' JOIN '
.
$
join
[
'joinTable'
]
.
' '
.
$join
[
'joinAlias'
]
.
' JOIN '
.
$
this
->
connection
->
quoteIdentifier
(
$join
[
'joinTable'
])
.
' '
.
$join
[
'joinAlias'
]
.
' ON '
.
((
string
)
$join
[
'joinCondition'
]);
.
' ON '
.
((
string
)
$join
[
'joinCondition'
]);
$knownAliases
[
$join
[
'joinAlias'
]]
=
true
;
$knownAliases
[
$join
[
'joinAlias'
]]
=
true
;
...
...
tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php
View file @
11111bd7
This diff is collapsed.
Click to expand it.
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