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
3965d4f5
Commit
3965d4f5
authored
Aug 29, 2012
by
Benjamin Eberlei
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #192 from Xobb/master
ExpressionBuilder in and notIn methods
parents
bb88ba71
f812cc8c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
0 deletions
+36
-0
ExpressionBuilder.php
lib/Doctrine/DBAL/Query/Expression/ExpressionBuilder.php
+26
-0
ExpressionBuilderTest.php
...ine/Tests/DBAL/Query/Expression/ExpressionBuilderTest.php
+10
-0
No files found.
lib/Doctrine/DBAL/Query/Expression/ExpressionBuilder.php
View file @
3965d4f5
...
@@ -249,6 +249,32 @@ class ExpressionBuilder
...
@@ -249,6 +249,32 @@ class ExpressionBuilder
return
$this
->
comparison
(
$x
,
'LIKE'
,
$y
);
return
$this
->
comparison
(
$x
,
'LIKE'
,
$y
);
}
}
/**
* Creates a IN () comparison expression with the given arguments.
*
* @param string $x field in string format to be inspected by IN() comparison.
* @param array $y Array of values to be used by IN() comparison.
*
* @return string
*/
public
function
in
(
$x
,
array
$y
)
{
return
$this
->
comparison
(
$x
,
'IN'
,
'('
.
implode
(
', '
,
$y
)
.
')'
);
}
/**
* Creates a NOT IN () comparison expression with the given arguments.
*
* @param string $x field in string format to be inspected by NOT IN() comparison.
* @param array $y Array of values to be used by NOT IN() comparison.
*
* @return string
*/
public
function
notIn
(
$x
,
array
$y
)
{
return
$this
->
comparison
(
$x
,
'NOT IN'
,
'('
.
implode
(
', '
,
$y
)
.
')'
);
}
/**
/**
* Quotes a given input parameter.
* Quotes a given input parameter.
*
*
...
...
tests/Doctrine/Tests/DBAL/Query/Expression/ExpressionBuilderTest.php
View file @
3965d4f5
...
@@ -198,4 +198,14 @@ class ExpressionBuilderTest extends \Doctrine\Tests\DbalTestCase
...
@@ -198,4 +198,14 @@ class ExpressionBuilderTest extends \Doctrine\Tests\DbalTestCase
{
{
$this
->
assertEquals
(
'u.updated IS NOT NULL'
,
$this
->
expr
->
isNotNull
(
'u.updated'
));
$this
->
assertEquals
(
'u.updated IS NOT NULL'
,
$this
->
expr
->
isNotNull
(
'u.updated'
));
}
}
public
function
testIn
()
{
$this
->
assertEquals
(
'u.groups IN (1, 3, 4, 7)'
,
$this
->
expr
->
in
(
'u.groups'
,
array
(
1
,
3
,
4
,
7
)));
}
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
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