Skip to content

Commit

Permalink
minor doc fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
qiangxue committed Jul 14, 2013
1 parent 494fb8f commit 4f70506
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions docs/guide/active-record.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,10 @@ $values = $customer->attributes;
```


Persisting Data to Database
---------------------------
Saving Data to Database
-----------------------

ActiveRecord provides the following methods to insert, update and delete data:
ActiveRecord provides the following methods to insert, update and delete data in the database:

- [[save()]]
- [[insert()]]
Expand Down Expand Up @@ -207,9 +207,9 @@ a one-many relationship. For example, a customer has many orders. And the [[hasO
method declares a many-one or one-one relationship. For example, an order has one customer.
Both methods take two parameters:

- `$class`: the name of the class related models should use. If specified without
a namespace, the namespace will be taken from the declaring class.
- `$link`: the association between columns from two tables. This should be given as an array.
- `$class`: the name of the class of the related model(s). If specified without
a namespace, the namespace of the related model class will be taken from the declaring class.
- `$link`: the association between columns from the two tables. This should be given as an array.
The keys of the array are the names of the columns from the table associated with `$class`,
while the values of the array are the names of the columns from the declaring class.
It is a good practice to define relationships based on table foreign keys.
Expand Down Expand Up @@ -263,8 +263,8 @@ class Order extends \yii\db\ActiveRecord
```

[[ActiveRelation::via()]] method is similar to [[ActiveRelation::viaTable()]] except that
the first parameter of [[ActiveRelation::via()]] takes a relation name declared in the ActiveRecord class.
For example, the above `items` relation can be equivalently declared as follows:
the first parameter of [[ActiveRelation::via()]] takes a relation name declared in the ActiveRecord class
instead of the pivot table name. For example, the above `items` relation can be equivalently declared as follows:

```php
class Order extends \yii\db\ActiveRecord
Expand Down Expand Up @@ -315,7 +315,7 @@ How many SQL queries will be performed in the above code, assuming there are mor
the database? 101! The first SQL query brings back 100 customers. Then for each customer, a SQL query
is performed to bring back the customer's orders.

To solve the above performance problem, you can use the so-called *eager loading* by calling [[ActiveQuery::with()]]:
To solve the above performance problem, you can use the so-called *eager loading* approach by calling [[ActiveQuery::with()]]:

```php
// SQL executed: SELECT * FROM tbl_customer LIMIT 100
Expand Down Expand Up @@ -473,7 +473,7 @@ TODO: FIXME: WIP, TBD, https://github.com/yiisoft/yii2/issues/226

Imagine situation where you have to save something related to the main model in [[beforeSave()]],
[[afterSave()]], [[beforeDelete()]] and/or [[afterDelete()]] life cycle methods. Developer may come
to solution of overriding ActiveRecord [[save()]] method with database transaction wrapping or
to the solution of overriding ActiveRecord [[save()]] method with database transaction wrapping or
even using transaction in controller action, which is strictly speaking doesn't seems to be a good
practice (recall skinny-controller fat-model fundamental rule).

Expand Down

0 comments on commit 4f70506

Please sign in to comment.