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
...
@@ -615,7 +615,46 @@ class ActiveQuery extends Query implements ActiveQueryInterface
{
{
$this
->
on
=
$condition
;
$this
->
on
=
$condition
;
$this
->
addParams
(
$params
);
$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
;
return
$this
;
}
}
...
...
framework/db/ActiveQueryTrait.php
View file @
a35ef1ce
...
@@ -30,6 +30,7 @@ trait ActiveQueryTrait
...
@@ -30,6 +30,7 @@ trait ActiveQueryTrait
*/
*/
public
$asArray
;
public
$asArray
;
/**
/**
* Sets the [[asArray]] property.
* Sets the [[asArray]] property.
* @param boolean $value whether to return the query results in terms of arrays instead of Active Records.
* @param boolean $value whether to return the query results in terms of arrays instead of Active Records.
...
@@ -38,7 +39,6 @@ trait ActiveQueryTrait
...
@@ -38,7 +39,6 @@ trait ActiveQueryTrait
public
function
asArray
(
$value
=
true
)
public
function
asArray
(
$value
=
true
)
{
{
$this
->
asArray
=
$value
;
$this
->
asArray
=
$value
;
return
$this
;
return
$this
;
}
}
...
...
framework/db/QueryTrait.php
View file @
a35ef1ce
...
@@ -49,6 +49,7 @@ trait QueryTrait
...
@@ -49,6 +49,7 @@ trait QueryTrait
*/
*/
public
$indexBy
;
public
$indexBy
;
/**
/**
* Sets the [[indexBy]] property.
* Sets the [[indexBy]] property.
* @param string|callable $column the name of the column by which the query results should be indexed by.
* @param string|callable $column the name of the column by which the query results should be indexed by.
...
@@ -67,7 +68,6 @@ trait QueryTrait
...
@@ -67,7 +68,6 @@ trait QueryTrait
public
function
indexBy
(
$column
)
public
function
indexBy
(
$column
)
{
{
$this
->
indexBy
=
$column
;
$this
->
indexBy
=
$column
;
return
$this
;
return
$this
;
}
}
...
@@ -84,7 +84,6 @@ trait QueryTrait
...
@@ -84,7 +84,6 @@ trait QueryTrait
public
function
where
(
$condition
)
public
function
where
(
$condition
)
{
{
$this
->
where
=
$condition
;
$this
->
where
=
$condition
;
return
$this
;
return
$this
;
}
}
...
@@ -104,7 +103,6 @@ trait QueryTrait
...
@@ -104,7 +103,6 @@ trait QueryTrait
}
else
{
}
else
{
$this
->
where
=
[
'and'
,
$this
->
where
,
$condition
];
$this
->
where
=
[
'and'
,
$this
->
where
,
$condition
];
}
}
return
$this
;
return
$this
;
}
}
...
@@ -124,7 +122,6 @@ trait QueryTrait
...
@@ -124,7 +122,6 @@ trait QueryTrait
}
else
{
}
else
{
$this
->
where
=
[
'or'
,
$this
->
where
,
$condition
];
$this
->
where
=
[
'or'
,
$this
->
where
,
$condition
];
}
}
return
$this
;
return
$this
;
}
}
...
@@ -144,7 +141,6 @@ trait QueryTrait
...
@@ -144,7 +141,6 @@ trait QueryTrait
public
function
orderBy
(
$columns
)
public
function
orderBy
(
$columns
)
{
{
$this
->
orderBy
=
$this
->
normalizeOrderBy
(
$columns
);
$this
->
orderBy
=
$this
->
normalizeOrderBy
(
$columns
);
return
$this
;
return
$this
;
}
}
...
@@ -166,7 +162,6 @@ trait QueryTrait
...
@@ -166,7 +162,6 @@ trait QueryTrait
}
else
{
}
else
{
$this
->
orderBy
=
array_merge
(
$this
->
orderBy
,
$columns
);
$this
->
orderBy
=
array_merge
(
$this
->
orderBy
,
$columns
);
}
}
return
$this
;
return
$this
;
}
}
...
@@ -184,7 +179,6 @@ trait QueryTrait
...
@@ -184,7 +179,6 @@ trait QueryTrait
$result
[
$column
]
=
SORT_ASC
;
$result
[
$column
]
=
SORT_ASC
;
}
}
}
}
return
$result
;
return
$result
;
}
}
}
}
...
@@ -197,7 +191,6 @@ trait QueryTrait
...
@@ -197,7 +191,6 @@ trait QueryTrait
public
function
limit
(
$limit
)
public
function
limit
(
$limit
)
{
{
$this
->
limit
=
$limit
;
$this
->
limit
=
$limit
;
return
$this
;
return
$this
;
}
}
...
@@ -209,7 +202,6 @@ trait QueryTrait
...
@@ -209,7 +202,6 @@ trait QueryTrait
public
function
offset
(
$offset
)
public
function
offset
(
$offset
)
{
{
$this
->
offset
=
$offset
;
$this
->
offset
=
$offset
;
return
$this
;
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