Skip to content

Commit

Permalink
doc improvement [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
qiangxue committed Apr 10, 2015
1 parent 36a0e83 commit 6fe5d08
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions docs/guide/db-active-record.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,10 @@ named in this way. If you are concerned about code style consistency, you should

### Data Transformation <span id="data-transformation"></span>

It often happens that the data being entered and/or displayed are in a different format from the one used in
It often happens that the data being entered and/or displayed are in a format which is different from the one used in
storing the data in a database. For example, in the database you are storing customers' birthdays as UNIX timestamps
(which is not a good design, though), while in most cases you would like to manipulate birthdays as strings in
the format of `'YYYY/MM/DD'`. To achieve this goal, you can define data transformation methods in the `Customer`
the format of `'YYYY/MM/DD'`. To achieve this goal, you can define *data transformation* methods in the `Customer`
Active Record class like the following:

```php
Expand All @@ -275,9 +275,9 @@ class Customer extends ActiveRecord
Now in your PHP code, instead of accessing `$customer->birthday`, you would access `$customer->birthdayText`, which
will allow you to input and display customer birthdays in the format of `'YYYY/MM/DD'`.

> Tip: the above shows an easy approach to achieve data transformation in general. For date values Yii provides a better
> way using the [DateValidator](tutorial-core-validators.md#date) and a DatePicker widget, which is described in the
> [JUI Widgets section](widget-jui#datepicker-date-input).
> Tip: The above example shows a generic way of transforming data in different formats. If you are working with
> date values, you may use [DateValidator](tutorial-core-validators.md#date) and [[yii\jui\DatePicker|DatePicker]],
> which is easier to use and more powerful.

### Retrieving Data in Arrays <span id="data-in-arrays"></span>
Expand Down

0 comments on commit 6fe5d08

Please sign in to comment.