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
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Rotua Panjaitan
yii2
Commits
aa925129
Commit
aa925129
authored
Nov 23, 2014
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improved doc [skip ci]
parent
646f233f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
2 deletions
+4
-2
db-active-record.md
docs/guide/db-active-record.md
+4
-2
No files found.
docs/guide/db-active-record.md
View file @
aa925129
...
...
@@ -198,8 +198,10 @@ $customer = Customer::findAll([
]);
```
> Note: Neither `findOne()` nor `one()` adds `LIMIT 1` to the query so if you need "any active customer"
you should add limit manually i.e.
`Customer::find()->where(['status' => Customer::STATUS_ACTIVE])->limit(1)->one();`
.
> Note: By default neither `findOne()` nor `one()` will add `LIMIT 1` to the query. This is fine and preferred
if you know the query will return only one or a few rows of data (e.g. if you are querying with some primary keys).
However, if the query may potentially return many rows of data, you should call
`limit(1)`
to improve the performance.
For example,
`Customer::find()->where(['status' => Customer::STATUS_ACTIVE])->limit(1)->one()`
.
### Retrieving Data in Arrays
...
...
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