Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Rotua Panjaitan
yii2
Commits
febce763
Commit
febce763
authored
Jan 11, 2014
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed build break and fixed doc about exists/not exists.
parent
4037e5c1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
1 deletion
+11
-1
query-builder.md
docs/guide/query-builder.md
+3
-0
Query.php
framework/db/Query.php
+5
-0
QueryBuilder.php
framework/db/QueryBuilder.php
+3
-1
No files found.
docs/guide/query-builder.md
View file @
febce763
...
...
@@ -158,6 +158,9 @@ Operator can be one of the following:
in the generated condition.
-
`or not like`
: similar to the
`not like`
operator except that
`OR`
is used to concatenate
the
`NOT LIKE`
predicates.
-
`exists`
: requires one operand which must be an instance of
[
[Query
]
] representing the sub-query.
It will build a
`EXISTS (sub-query)`
expression.
-
`not exists`
: similar to the
`exists`
operator and builds a
`NOT EXISTS (sub-query)`
expression.
If you are building parts of condition dynamically it's very convenient to use
`andWhere`
and
`orWhere`
:
...
...
framework/db/Query.php
View file @
febce763
...
...
@@ -404,6 +404,11 @@ class Query extends Component implements QueryInterface
* - `or not like`: similar to the `not like` operator except that `OR` is used to concatenate
* the `NOT LIKE` predicates.
*
* - `exists`: requires one operand which must be an instance of [[Query]] representing the sub-query.
* It will build a `EXISTS (sub-query)` expression.
*
* - `not exists`: similar to the `exists` operator and builds a `NOT EXISTS (sub-query)` expression.
*
* @param string|array $condition the conditions that should be put in the WHERE part.
* @param array $params the parameters (name => value) to be bound to the query.
* @return static the query object itself
...
...
framework/db/QueryBuilder.php
View file @
febce763
...
...
@@ -1077,7 +1077,7 @@ class QueryBuilder extends \yii\base\Object
/**
* Creates an SQL expressions with the `EXISTS` operator.
* @param string $operator the operator to use (e.g. `EXISTS` or `NOT EXISTS`)
* @param array $operands contains only
the one element. It is sub-query
* @param array $operands contains only
one element which is a [[Query]] object representing the sub-query.
* @param array $params the binding parameters to be populated
* @return string the generated SQL expression
*/
...
...
@@ -1085,9 +1085,11 @@ class QueryBuilder extends \yii\base\Object
{
$subQuery
=
$operands
[
0
];
list
(
$subQuerySql
,
$subQueryParams
)
=
$this
->
build
(
$subQuery
);
if
(
!
empty
(
$subQueryParams
))
{
foreach
(
$subQueryParams
as
$name
=>
$value
)
{
$params
[
$name
]
=
$value
;
}
}
return
"
$operator
(
$subQuerySql
)"
;
}
}
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