88 Commits

Author SHA1 Message Date
25e6eb04a5 refs #11122: Fixed can not use orderBy with aggregate functions (#12772)
* refs #11122: Fixed can not use `orderBy` with aggregate functions like `count`, `max` etc.

* Update QueryTest.php
2016-12-18 11:28:34 +02:00
350e93e626 Fixes #12612: Query conditions added with yii\db\Query::andWhere() now get appended to the existing conditions if they were already being joined with the and operator 2016-12-16 13:19:14 +03:00
518be6b8ec Enhanced PHPDocs markup 2016-12-14 23:07:44 +02:00
837b33767c Fixes #11697: Added filterHaving(), andFilterHaving() and orFilterHaving() to yii\db\Query
Signed-off-by: Alexander Makarov <sam@rmcreative.ru>
2016-12-14 23:58:04 +03:00
e78a7fe20e Initial work on #11697 2016-12-14 23:57:02 +03:00
c17766181f Added QueryInterface::emulateExecution()
Added `QueryInterface::emulateExecution()`, which allows preventing of
the actual query execution.
This allows to cancel `DataProvider` preventing search query execution
in case search model is invalid:

``` php
public function search($params)
    {
        $query = Item::find();

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
        ]);

        $this->load($params);

        if (!$this->validate()) {
            $query->where('0=1');
            $query->emulateExecution(); // No SQL execution will be done
            return $dataProvider;
        }
```

This also fix unecessary query in case of `via()` usage. See #12390.

fixes #12390
fixes #6373
close #12708
2016-12-02 13:28:51 +01:00
4aa935e69e Fixes #12055: Changed boolean to bool and integer to int in phpdoc 2016-11-07 02:51:39 +03:00
677b55475b Reverted accidental commit 2016-10-12 00:38:54 +03:00
2ffa670885 add functions for filtering 2016-10-12 00:07:45 +03:00
e7195da4b3 Fix yii\db\Query::having phpdoc [skip ci] 2016-10-04 21:24:52 +02:00
95152f3c2c Fixed consistency of indexBy handling for yii\db\Query::column()
Closes #12649
2016-10-03 11:17:32 +03:00
d33227ab85 typo fix (#12217) [skip ci] 2016-08-21 12:58:11 +03:00
0061692e60 Replaced unnecessary double quotes with single quotes 2016-07-29 22:56:38 +03:00
e4dc2026bc note about JOIN syntax
fixes #7549
2016-06-20 13:04:08 +02:00
dbb54f986c Updated phpDoc of scalar 2016-05-25 09:14:31 +03:00
4411a74ebd proper fix for #9425, adjust changes from #11363
includes tests and fix that works in all cases.
2016-04-28 01:29:07 +02:00
f8a844a90f Query helper method for filter values containing operators
Basic implementation proposal for yiisoft/yii2#2022

Shortcomings/todo's:
* filtering on non-scalars (where IN statements) not supported
* Numeric properties with a corresponding validation rule will yield
  errors when they contain an alphanumeric operator. These properties'
  rules should be defined as 'string' or 'safe'.
* no implementation example in Gii code (yet).

close #8505
2016-04-22 14:05:24 +02:00
73eb62a3cd DBMS specific workarounds for unsupported SQL92 form of SELECT EXISTS() (#11369) 2016-04-17 17:44:52 +03:00
806eb57990 Fixes #9425: ActiveQuery::exists() should generate SELECT EXISTS() (#11363) 2016-04-16 13:34:20 +03:00
191f2a4943 fixed phpdoc type names 2016-02-25 20:24:32 +01:00
e43c41c9ea db layer phpdoc fixes 2016-02-07 16:33:26 +01:00
5a462dc5d2 added tests and documentation for #8824 2016-01-27 16:26:43 +01:00
468886a77b small refactoring for #9452 2015-12-06 06:04:46 +01:00
cd87d67f34 Global DOCS update: ~~~ replaced with ``` 2015-12-02 23:15:28 +02:00
7c7ed48c4c cleanup docs and duplicate code in query 2015-11-25 23:31:29 +01:00
decd45201c allow passing a single Expression object to select() and addSelect()
fixes #9883
2015-10-11 09:58:42 +02:00
4e7adc13ea adjusted docs about Query::from() and subqueries
also added a  test to verify behavior

close #9720
close #9266
2015-09-19 17:41:45 +02:00
a2f70f6484 Update Query doc return type
When used ActiveQuery chain call after call any of join type IDE cannot resolve ActiveQuery methods such an asArray
Example:
SomeActiveRecordModel::find()
            ->select('...') // return ActiveQuery
            ->leftJoin('...', '...') // return Query
            ->asArray() // it's become undefined
            ->column();
2015-08-21 17:14:00 +03:00
68c30c1034 Replace aliases of functions 2015-06-29 22:59:22 +03:00
ae42a054bb PSR-2 spaces, commas, etc 2015-06-09 00:05:06 +03:00
f68e970de2 link to PHP classes just as we do with normal classes
apidoc can handle this!
2015-06-05 21:53:24 +02:00
67658cf57d Replaced static with $this in phpdoc since current IDEs are finally able to handle it correctly 2015-05-31 13:39:30 +03:00
1cfc40d6e5 link to the guide on quoting from query phpdoc
fixes #8141
2015-04-20 23:24:01 +02:00
f99f333218 added note to docs about #8085 2015-04-15 10:03:42 +02:00
b8081b59b3 Fixed yii\db\Query::count() fails for query containing 'having' without 'group by' 2015-04-14 16:11:07 +03:00
aead65f2d2 Fixes #7515: Added support to use indexBy() together with column() in query builder 2015-04-08 22:54:30 -04:00
4267b53d43 added doc about count() return value
fixes #yiisoft/yii#3712
2015-01-14 18:33:41 +01:00
5ad6ba5c9e Fix from e719ff5 moved to yii\sphinx\Query 2014-12-23 18:39:52 +02:00
e719ff5854 yii\db\Query::queryScalar() fixed to use static when creating subquery 2014-12-23 18:17:17 +02:00
2544e86d2c Fixes #5735: Added yii\bootstrap\Tabs::renderTabContent to support manually rendering tab contents 2014-10-24 07:54:48 -04:00
5acf17e658 Fixed phpdoc for yii\db\Query [skip ci] 2014-10-05 11:24:40 +04:00
9df21d46f3 reverted addition of $where property 2014-09-24 13:39:03 +02:00
222f9ddfad added missing documentation about the NOT operator in Query
fixes #5147
2014-09-24 12:53:33 +02:00
b9c97ff2aa Fixes #4938: When yii\db\ActiveQuery is used to build sub-queries, its WHERE clause is not correctly generated 2014-09-12 16:46:12 -04:00
2f4a09ef53 phpdoc 2014-06-25 19:33:29 +02:00
91965fd391 phpdoc formatting issues 2014-04-23 02:55:17 +02:00
76d8e2b5b3 code style, fixes #3140 2014-04-17 13:24:16 +02:00
a60d295253 Added support for using sub-queries when building a DB query with IN condition 2014-04-15 20:20:18 -04:00
cee5fa5dd3 New addSelect method
New addSelect method. Useful for scopes.
2014-04-08 12:10:29 +01:00
0fa19291f1 refactored filterWhere(). 2014-04-02 20:03:42 -04:00