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
1b35a53e
Commit
1b35a53e
authored
Oct 23, 2014
by
Guilherme Blanco
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #680 from hason/in
Enabled placeholders for "in" method in ExpressionBuilder
parents
040d49c1
cc0dfa85
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
9 deletions
+19
-9
ExpressionBuilder.php
lib/Doctrine/DBAL/Query/Expression/ExpressionBuilder.php
+8
-8
ExpressionBuilderTest.php
...ine/Tests/DBAL/Query/Expression/ExpressionBuilderTest.php
+11
-1
No files found.
lib/Doctrine/DBAL/Query/Expression/ExpressionBuilder.php
View file @
1b35a53e
...
...
@@ -275,27 +275,27 @@ class ExpressionBuilder
/**
* Creates a IN () comparison expression with the given arguments.
*
* @param string $x The field in string format to be inspected by IN() comparison.
* @param
array $y T
he array of values to be used by IN() comparison.
* @param string
$x The field in string format to be inspected by IN() comparison.
* @param
string|array $y The placeholder or t
he array of values to be used by IN() comparison.
*
* @return string
*/
public
function
in
(
$x
,
array
$y
)
public
function
in
(
$x
,
$y
)
{
return
$this
->
comparison
(
$x
,
'IN'
,
'('
.
implode
(
', '
,
$y
)
.
')'
);
return
$this
->
comparison
(
$x
,
'IN'
,
'('
.
implode
(
', '
,
(
array
)
$y
)
.
')'
);
}
/**
* Creates a NOT IN () comparison expression with the given arguments.
*
* @param string $x The field in string format to be inspected by NOT IN() comparison.
* @param
array $y T
he array of values to be used by NOT IN() comparison.
* @param string
$x The field in string format to be inspected by NOT IN() comparison.
* @param
string|array $y The placeholder or t
he array of values to be used by NOT IN() comparison.
*
* @return string
*/
public
function
notIn
(
$x
,
array
$y
)
public
function
notIn
(
$x
,
$y
)
{
return
$this
->
comparison
(
$x
,
'NOT IN'
,
'('
.
implode
(
', '
,
$y
)
.
')'
);
return
$this
->
comparison
(
$x
,
'NOT IN'
,
'('
.
implode
(
', '
,
(
array
)
$y
)
.
')'
);
}
/**
...
...
tests/Doctrine/Tests/DBAL/Query/Expression/ExpressionBuilderTest.php
View file @
1b35a53e
...
...
@@ -204,8 +204,18 @@ class ExpressionBuilderTest extends \Doctrine\Tests\DbalTestCase
$this
->
assertEquals
(
'u.groups IN (1, 3, 4, 7)'
,
$this
->
expr
->
in
(
'u.groups'
,
array
(
1
,
3
,
4
,
7
)));
}
public
function
testInWithPlaceholder
()
{
$this
->
assertEquals
(
'u.groups IN (?)'
,
$this
->
expr
->
in
(
'u.groups'
,
'?'
));
}
public
function
testNotIn
()
{
$this
->
assertEquals
(
'u.groups NOT IN (1, 3, 4, 7)'
,
$this
->
expr
->
notIn
(
'u.groups'
,
array
(
1
,
3
,
4
,
7
)));
}
}
\ No newline at end of file
public
function
testNotInWithPlaceholder
()
{
$this
->
assertEquals
(
'u.groups NOT IN (:values)'
,
$this
->
expr
->
notIn
(
'u.groups'
,
':values'
));
}
}
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