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
3efabd49
Unverified
Commit
3efabd49
authored
Feb 08, 2018
by
Grégoire Paris
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cs
parent
4c6e6bbf
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
4 deletions
+10
-4
AbstractPlatform.php
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
+5
-2
SQLServer2008Platform.php
lib/Doctrine/DBAL/Platforms/SQLServer2008Platform.php
+3
-0
LikeWildcardsEscapingTest.php
...trine/Tests/DBAL/Functional/LikeWildcardsEscapingTest.php
+2
-2
No files found.
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
View file @
3efabd49
...
@@ -3592,14 +3592,17 @@ abstract class AbstractPlatform
...
@@ -3592,14 +3592,17 @@ abstract class AbstractPlatform
*/
*/
final
public
function
escapeStringForLike
(
string
$inputString
,
string
$escapeChar
)
:
string
final
public
function
escapeStringForLike
(
string
$inputString
,
string
$escapeChar
)
:
string
{
{
$replacePairs
=
[
$escapeChar
=>
$escapeChar
.
$escapeChar
];
$replacePairs
=
[
$escapeChar
=>
$escapeChar
.
$escapeChar
];
foreach
(
$this
->
getLikeWildcardCharacters
()
as
$wildcardChar
)
{
foreach
(
$this
->
getLikeWildcardCharacters
()
as
$wildcardChar
)
{
$replacePairs
[
$wildcardChar
]
=
$escapeChar
.
$wildcardChar
;
$replacePairs
[
$wildcardChar
]
=
$escapeChar
.
$wildcardChar
;
}
}
return
strtr
(
$inputString
,
$replacePairs
);
return
strtr
(
$inputString
,
$replacePairs
);
}
}
/**
* @return string[]
*/
protected
function
getLikeWildcardCharacters
()
:
iterable
protected
function
getLikeWildcardCharacters
()
:
iterable
{
{
return
[
'%'
,
'_'
];
return
[
'%'
,
'_'
];
...
...
lib/Doctrine/DBAL/Platforms/SQLServer2008Platform.php
View file @
3efabd49
...
@@ -117,6 +117,9 @@ class SQLServer2008Platform extends SQLServer2005Platform
...
@@ -117,6 +117,9 @@ class SQLServer2008Platform extends SQLServer2005Platform
return
Keywords\SQLServer2008Keywords
::
class
;
return
Keywords\SQLServer2008Keywords
::
class
;
}
}
/**
* {@inheritDoc}
*/
protected
function
getLikeWildcardCharacters
()
:
iterable
protected
function
getLikeWildcardCharacters
()
:
iterable
{
{
return
array_merge
(
parent
::
getLikeWildcardCharacters
(),
[
'['
,
']'
,
'^'
]);
return
array_merge
(
parent
::
getLikeWildcardCharacters
(),
[
'['
,
']'
,
'^'
]);
...
...
tests/Doctrine/Tests/DBAL/Functional/LikeWildcardsEscapingTest.php
View file @
3efabd49
...
@@ -8,9 +8,9 @@ final class LikeWildcardsEscapingTest extends DbalFunctionalTestCase
...
@@ -8,9 +8,9 @@ final class LikeWildcardsEscapingTest extends DbalFunctionalTestCase
{
{
public
function
testFetchLikeExpressionResult
()
:
void
public
function
testFetchLikeExpressionResult
()
:
void
{
{
$string
=
'_25% off_ your next purchase \o/'
;
$string
=
'_25% off_ your next purchase \o/'
;
$escapeChar
=
'!'
;
$escapeChar
=
'!'
;
$stmt
=
$this
->
_conn
->
prepare
(
sprintf
(
$stmt
=
$this
->
_conn
->
prepare
(
sprintf
(
"SELECT '%s' LIKE '%s' ESCAPE '%s' as it_matches"
,
"SELECT '%s' LIKE '%s' ESCAPE '%s' as it_matches"
,
$string
,
$string
,
$this
->
_conn
->
getDatabasePlatform
()
->
escapeStringForLike
(
$string
,
$escapeChar
),
$this
->
_conn
->
getDatabasePlatform
()
->
escapeStringForLike
(
$string
,
$escapeChar
),
...
...
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