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
292a9ff5
Commit
292a9ff5
authored
Oct 17, 2014
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for yii\db\Expression to QueryBuiler simple conditions
fixes #5601
parent
179be14c
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
18 additions
and
3 deletions
+18
-3
CHANGELOG.md
extensions/sphinx/CHANGELOG.md
+2
-1
QueryBuilder.php
extensions/sphinx/QueryBuilder.php
+5
-0
CHANGELOG.md
framework/CHANGELOG.md
+3
-2
QueryBuilder.php
framework/db/QueryBuilder.php
+5
-0
QueryBuilderTest.php
tests/unit/framework/db/QueryBuilderTest.php
+3
-0
No files found.
extensions/sphinx/CHANGELOG.md
View file @
292a9ff5
...
...
@@ -4,7 +4,7 @@ Yii Framework 2 sphinx extension Change Log
2.
0.1 under development
-----------------------
-
no changes in this release.
-
Bug #5601: Simple conditions in Query::where() and ActiveQuery::where() did not allow
`yii\db\Expression`
to be used as the value (cebe, stevekr)
2.0.0 October 12, 2014
...
...
@@ -41,6 +41,7 @@ Yii Framework 2 sphinx extension Change Log
All relational queries are now directly served by
`ActiveQuery`
allowing to use
custom scopes in relations (cebe)
2.0.0-alpha, December 1, 2013
-----------------------------
...
...
extensions/sphinx/QueryBuilder.php
View file @
292a9ff5
...
...
@@ -1085,6 +1085,11 @@ class QueryBuilder extends Object
if
(
$value
===
null
)
{
return
"
$column
$operator
NULL"
;
}
elseif
(
$value
instanceof
Expression
)
{
foreach
(
$value
->
params
as
$n
=>
$v
)
{
$params
[
$n
]
=
$v
;
}
return
"
$column
$operator
{
$value
->
expression
}
"
;
}
else
{
$phName
=
self
::
PARAM_PREFIX
.
count
(
$params
);
$params
[
$phName
]
=
$value
;
...
...
framework/CHANGELOG.md
View file @
292a9ff5
...
...
@@ -4,10 +4,11 @@ Yii Framework 2 Change Log
2.
0.1 under development
-----------------------
-
Enh #5600: Allow configuring debug panels in
`yii\debug\Module::panels`
as panel class name strings (qiangxue)
-
Enh #5613: Added
`--overwrite`
option to Gii console command to support overwriting all files (motin, qiangxue)
-
Bug #5584:
`yii\rbac\DbRbacManager`
should not delete items when deleting a rule on a database not supporting cascade update (mdmunir)
-
Bug #5601: Simple conditions in Query::where() and ActiveQuery::where() did not allow
`yii\db\Expression`
to be used as the value (cebe, stevekr)
-
Bug: Gii console command help information does not contain global options (qiangxue)
-
Enh #5600: Allow configuring debug panels in
`yii\debug\Module::panels`
as panel class name strings (qiangxue)
-
Enh #5613: Added
`--overwrite`
option to Gii console command to support overwriting all files (motin, qiangxue)
2.0.0 October 12, 2014
...
...
framework/db/QueryBuilder.php
View file @
292a9ff5
...
...
@@ -1238,6 +1238,11 @@ class QueryBuilder extends \yii\base\Object
if
(
$value
===
null
)
{
return
"
$column
$operator
NULL"
;
}
elseif
(
$value
instanceof
Expression
)
{
foreach
(
$value
->
params
as
$n
=>
$v
)
{
$params
[
$n
]
=
$v
;
}
return
"
$column
$operator
{
$value
->
expression
}
"
;
}
else
{
$phName
=
self
::
PARAM_PREFIX
.
count
(
$params
);
$params
[
$phName
]
=
$value
;
...
...
tests/unit/framework/db/QueryBuilderTest.php
View file @
292a9ff5
...
...
@@ -2,6 +2,7 @@
namespace
yiiunit\framework\db
;
use
yii\db\Expression
;
use
yii\db\Query
;
use
yii\db\QueryBuilder
;
use
yii\db\Schema
;
...
...
@@ -193,6 +194,8 @@ class QueryBuilderTest extends DatabaseTestCase
[
[
'<='
,
'a'
,
'b'
],
'"a" <= :qp0'
,
[
':qp0'
=>
'b'
]
],
[
[
'<>'
,
'a'
,
3
],
'"a" <> :qp0'
,
[
':qp0'
=>
3
]
],
[
[
'!='
,
'a'
,
'b'
],
'"a" != :qp0'
,
[
':qp0'
=>
'b'
]
],
[
[
'>='
,
'date'
,
new
Expression
(
'DATE_SUB(NOW(), INTERVAL 1 MONTH)'
)],
'"date" >= DATE_SUB(NOW(), INTERVAL 1 MONTH)'
,
[]
],
[
[
'>='
,
'date'
,
new
Expression
(
'DATE_SUB(NOW(), INTERVAL :month MONTH)'
,
[
':month'
=>
2
])],
'"date" >= DATE_SUB(NOW(), INTERVAL :month MONTH)'
,
[
':month'
=>
2
]
],
];
// adjust dbms specific escaping
...
...
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