-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Small correction in DB\Query comments #1598
Conversation
I checked this using XDebug, and the function actually returns null (which is something different than false). I assume it is the comment that should be changed, and not the code itself...
Small correction in DB\Query comments
Thanks! |
This change is not correct. Reverted and verified in 795c741. |
@cebe this confuses me. Both the docs and Gii-generated code often use the following to check if an AR find has any results: $employee = Employee::find()->where('id = :id', [':id' => $id])->one();
if ($employee !== null) {
// do something
} Since |
AR uses ActiveQuery, not Query. ActiveQuery::one() returns an AR instance or null while Query::one() returns an array or false. |
@cebe alright thanks. Is there any reason why Query doesn't return null too? This would be a logical assumption that beginning Yii developers make (as I just did myself). Most people will learn to work with ActiveRecord first (since the gii-generated code is full of it), so maybe a Query should also return null in the absence of results? |
* upstream: (2012 commits) doc fix. Changed the signature of `urlCreator` and button creators for `yii\gridview\ActionColumn` parameter adjustment. The signature for `yii\gridview\ActionColumn::urlCreator` is changed - the `$action` parameter is moved to the first Fixed the signature of Schema::findUniqueIndexes(). reverted yiisoft#1598 and added a test for it Fix wrong array index in unique indexes for MySql Making accesors public Get DB unique indexes information Fixes yiisoft#1610: `Html::activeCheckboxList()` and `Html::activeRadioList()` will submit an empty string if no checkbox/radio is selected Gii should keep horizontal layout Documentation at "yii\authclient" updated. Doc comments at "yii\authclient" updated. Auth clients "Choice" doc comments updated. Auth clients "Choice" widget javascript advanced. Bootstrap's dropdown encodes also trailing caret tag Auth clients "Choice" widget markup updated. Gii should keep horizontal layout extended from codeception testcase, added docs Auth clients for Facebook, GitHub, LinkedIn added. ... Conflicts: framework/yii/helpers/BaseInflector.php tests/unit/framework/helpers/InflectorTest.php
Query returns false because it is a wrapper around PDO which returns false in case of no result. AR is another layer over Query and it uses null because it is dealing with objects. |
I checked this using XDebug, and the function actually returns null (which is something different than false). I assume it is the comment that should be changed, and not the code itself...