Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix the wrong Entity-Datamap usage instructions. #4937

Merged
merged 1 commit into from
Jul 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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