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
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
PSDI Army
yii2
Commits
a35ef1ce
Commit
a35ef1ce
authored
Apr 02, 2014
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added andOnCondition and orOnCondition to ActiveQuery
fixes #2957
parent
ac12f9ec
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
10 deletions
+41
-10
ActiveQuery.php
framework/db/ActiveQuery.php
+39
-0
ActiveQueryTrait.php
framework/db/ActiveQueryTrait.php
+1
-1
QueryTrait.php
framework/db/QueryTrait.php
+1
-9
No files found.
framework/db/ActiveQuery.php
View file @
a35ef1ce
...
...
@@ -615,7 +615,46 @@ class ActiveQuery extends Query implements ActiveQueryInterface
{
$this
->
on
=
$condition
;
$this
->
addParams
(
$params
);
return
$this
;
}
/**
* Adds an additional ON condition to the existing one.
* The new condition and the existing one will be joined using the 'AND' operator.
* @param string|array $condition the new ON condition. Please refer to [[where()]]
* on how to specify this parameter.
* @return static the query object itself
* @see onCondition()
* @see orOnCondition()
*/
public
function
andOnCondition
(
$condition
,
$params
=
[])
{
if
(
$this
->
on
===
null
)
{
$this
->
on
=
$condition
;
}
else
{
$this
->
on
=
[
'and'
,
$this
->
on
,
$condition
];
}
$this
->
addParams
(
$params
);
return
$this
;
}
/**
* Adds an additional ON condition to the existing one.
* The new condition and the existing one will be joined using the 'OR' operator.
* @param string|array $condition the new ON condition. Please refer to [[where()]]
* on how to specify this parameter.
* @return static the query object itself
* @see onCondition()
* @see andOnCondition()
*/
public
function
orOnCondition
(
$condition
,
$params
=
[])
{
if
(
$this
->
on
===
null
)
{
$this
->
on
=
$condition
;
}
else
{
$this
->
on
=
[
'or'
,
$this
->
on
,
$condition
];
}
$this
->
addParams
(
$params
);
return
$this
;
}
...
...
framework/db/ActiveQueryTrait.php
View file @
a35ef1ce
...
...
@@ -30,6 +30,7 @@ trait ActiveQueryTrait
*/
public
$asArray
;
/**
* Sets the [[asArray]] property.
* @param boolean $value whether to return the query results in terms of arrays instead of Active Records.
...
...
@@ -38,7 +39,6 @@ trait ActiveQueryTrait
public
function
asArray
(
$value
=
true
)
{
$this
->
asArray
=
$value
;
return
$this
;
}
...
...
framework/db/QueryTrait.php
View file @
a35ef1ce
...
...
@@ -49,6 +49,7 @@ trait QueryTrait
*/
public
$indexBy
;
/**
* Sets the [[indexBy]] property.
* @param string|callable $column the name of the column by which the query results should be indexed by.
...
...
@@ -67,7 +68,6 @@ trait QueryTrait
public
function
indexBy
(
$column
)
{
$this
->
indexBy
=
$column
;
return
$this
;
}
...
...
@@ -84,7 +84,6 @@ trait QueryTrait
public
function
where
(
$condition
)
{
$this
->
where
=
$condition
;
return
$this
;
}
...
...
@@ -104,7 +103,6 @@ trait QueryTrait
}
else
{
$this
->
where
=
[
'and'
,
$this
->
where
,
$condition
];
}
return
$this
;
}
...
...
@@ -124,7 +122,6 @@ trait QueryTrait
}
else
{
$this
->
where
=
[
'or'
,
$this
->
where
,
$condition
];
}
return
$this
;
}
...
...
@@ -144,7 +141,6 @@ trait QueryTrait
public
function
orderBy
(
$columns
)
{
$this
->
orderBy
=
$this
->
normalizeOrderBy
(
$columns
);
return
$this
;
}
...
...
@@ -166,7 +162,6 @@ trait QueryTrait
}
else
{
$this
->
orderBy
=
array_merge
(
$this
->
orderBy
,
$columns
);
}
return
$this
;
}
...
...
@@ -184,7 +179,6 @@ trait QueryTrait
$result
[
$column
]
=
SORT_ASC
;
}
}
return
$result
;
}
}
...
...
@@ -197,7 +191,6 @@ trait QueryTrait
public
function
limit
(
$limit
)
{
$this
->
limit
=
$limit
;
return
$this
;
}
...
...
@@ -209,7 +202,6 @@ trait QueryTrait
public
function
offset
(
$offset
)
{
$this
->
offset
=
$offset
;
return
$this
;
}
}
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