Skip to content

Commit fc500d0

Browse files
authored
Merge pull request #8259 from kenjis/docs-improve-entities
docs: improve Entities
2 parents 35a8f74 + 544093a commit fc500d0

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

user_guide_src/source/models/entities.rst

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Using Entity Classes
33
#####################
44

5-
CodeIgniter supports Entity classes as a first-class citizen in it's database layer, while keeping
5+
CodeIgniter supports Entity classes as a first-class citizen, while keeping
66
them completely optional to use. They are commonly used as part of the Repository pattern, but can
77
be used directly with the :doc:`Model </models/model>` if that fits your needs better.
88

@@ -16,9 +16,17 @@ Entity Usage
1616

1717
At its core, an Entity class is simply a class that represents a single database row. It has class properties
1818
to represent the database columns, and provides any additional methods to implement the business logic for
19-
that row. The core feature, though, is that it doesn't know anything about how to persist itself. That's the
19+
that row.
20+
21+
.. note:: For ease of understanding, the explanation here is based on the case of
22+
using a database. However, Entity can also be used for data that does not come
23+
from a database.
24+
25+
The core feature, though, is that it doesn't know anything about how to persist itself. That's the
2026
responsibility of the model or the repository class. That way, if anything changes on how you need to save the
21-
object, you don't have to change how that object is used throughout the application. This makes it possible to
27+
object, you don't have to change how that object is used throughout the application.
28+
29+
This makes it possible to
2230
use JSON or XML files to store the objects during a rapid prototyping stage, and then easily switch to a
2331
database when you've proven the concept works.
2432

@@ -70,7 +78,7 @@ access them as if they were public properties. The base class, ``CodeIgniter\Ent
7078
well as providing the ability to check the properties with ``isset()``, or ``unset()`` the property, and keep track
7179
of what columns have changed since the object was created or pulled from the database.
7280

73-
.. note:: The Entity class stores the data in the property ``$attributes``.
81+
.. note:: The Entity class stores the data in the class property ``$attributes`` internally.
7482

7583
When the User is passed to the model's ``save()`` method, it automatically takes care of reading the properties
7684
and saving any changes to columns listed in the model's ``$allowedFields`` property. It also knows whether to create

0 commit comments

Comments
 (0)