Skip to content

Commit

Permalink
Merge pull request #115 from baooab/5.3
Browse files Browse the repository at this point in the history
fix
  • Loading branch information
overtrue committed Jan 19, 2017
2 parents 2e172b9 + 41a1646 commit 6b36b51
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions eloquent.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ Eloquent 的 `all` 方法会返回在模型数据表中的所有结果。由于

#### 使用游标

`cursor` 允许你使用游标来遍历数据库数据。在处理数据量大的请求时 `cursor` 方法可以大幅度减少内存的使用:
`cursor` 允许你使用游标来遍历数据库数据,一次只执行单个查询。在处理大数据量请求时 `cursor` 方法可以大幅度减少内存的使用:


foreach (Flight::where('foo', 'bar')->cursor() as $flight) {
Expand Down Expand Up @@ -407,15 +407,12 @@ Eloquent 的 `all` 方法会返回在模型数据表中的所有结果。由于

#### 通过查询来删除模型

当然,你也可以在一组模型上运行删除查询。在这个例子中,我们将会删除所有被标示为不活跃的航班:

$deletedRows = App\Flight::where('active', 0)->delete();

In this example, we will delete all flights that are marked as inactive. Like mass updates, mass deletes will not fire any model events for the models that are deleted:
当然,你也可以运行在一组模型删除查询。在这个例子中,我们会删除被标记为不活跃的所有航班。 像批量更新那样,批量删除不会删除的任何被删除的模型的事件:

$deletedRows = App\Flight::where('active', 0)->delete();

>{note} 当使用 Eloquent 批量删除语句时,`deleting``deleted` 模型事件不会在被删除模型实例上触发。因为删除语句执行时,不会检索回模型实例。
<a name="soft-deleting"></a>
### 软删除

Expand Down Expand Up @@ -801,4 +798,4 @@ Eloquent 模型会触发许多事件,让你可以借助以下的方法在模
## 译者署名
| 用户名 | 头像 | 职能 | 签名 |
|---|---|---|---|
| [@LXY](https://github.com/dongli0) | <img class="avatar-66 rm-style" src="https://dn-phphub.qbox.me/uploads/avatars/5832_1473813539.jpeg?imageView2/1/w/380/h/380"> | 翻译 | PHP 小学生。 |
| [@LXY](https://github.com/dongli0) | <img class="avatar-66 rm-style" src="https://dn-phphub.qbox.me/uploads/avatars/5832_1473813539.jpeg?imageView2/1/w/380/h/380"> | 翻译 | PHP 小学生。 |

0 comments on commit 6b36b51

Please sign in to comment.