Skip to content

Commit

Permalink
fix entity-datamap guide wrong (#4937)
Browse files Browse the repository at this point in the history
  • Loading branch information
monkenWu authored Jul 19, 2021
1 parent 34f18b4 commit ac6cd3a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion system/Entity/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Entity implements JsonSerializable
*
* Example:
* $datamap = [
* 'db_name' => 'class_name'
* 'class_name' => 'db_name'
* ];
*/
protected $datamap = [];
Expand Down
6 changes: 3 additions & 3 deletions user_guide_src/source/models/entities.rst
Original file line number Diff line number Diff line change
Expand Up @@ -274,13 +274,13 @@ simply map the ``full_name`` column in the database to the ``$name`` property, a
];

protected $datamap = [
'full_name' => 'name',
'name' => 'full_name',
];
}

By adding our new database name to the ``$datamap`` array, we can tell the class what class property the database column
should be accessible through. The key of the array is the name of the column in the database, where the value in the array
is class property to map it to.
should be accessible through. The key of the array is class property to map it to, where the value in the array is the
name of the column in the database.

In this example, when the model sets the ``full_name`` field on the User class, it actually assigns that value to the
class' ``$name`` property, so it can be set and retrieved through ``$user->name``. The value will still be accessible
Expand Down

0 comments on commit ac6cd3a

Please sign in to comment.