Codeigniter, Web Development
Hello Friends,
Welcome to Part 38 of The CodeIgniter 4 Tutorial Series in Urdu/Hindi. Today in This Video Tutorial, We are going to learn about Entity Class and will Learn How to do Data Modeling using Entity Class with Examples in CodeIgniter 4.
CodeIgniter supports Entity classes as a first-class citizen in its database layer while keeping them completely optional to use. They are commonly used as part of the Repository pattern but can be used directly with the Model if that fits your needs better.
At its core, an Entity class is simply a class that represents a single database row. It has class properties to represent the database columns and provides any additional methods to implement the business logic for that row. The core feature, though, is that it doesn’t know anything about how to persist itself. That’s the responsibility of the model or the repository class. That way, if anything changes on how you need to save the object, you don’t have to change how that object is used throughout the application. This makes it possible to use JSON or XML files to store the objects during a rapid prototyping stage, and then easily switch to a database when you’ve proven the concept works.