The data access layer will consist of a User DAO class to provide database abstraction and an abstract Base DAO class to provide abstract methods, which is required for the User DAO class to be implemented. Also, we will create the abstract class to provide abstract methods for DAO classes to be created in our future projects. Note that we will use PHP namespace, My\Dao
, for the data access layer classes.
The abstract class will be used to provide a basic framework for subclasses to implement methods. Simply, the basic database operations are CRUD
or create, read, update
, and delete
. So, the abstract class will provide these types of abstract methods along with methods that will be required in every subclass. The BaseDao
abstract class will contain the final
method for database connectivity, so the subclasses don't need to write it again. To understand this better, we will keep our DAO classes in a separate directory named...