Using PDO for Data Management
- by edorahg
This question is more a design oriented question than a code specific question. I am new to PHP and I am planning to use PDO as a data access layer. Say for instance I have a class called CITY. Now if I need to create an instance of this class, what is the best technique.
Should have a singleton DB access class which is used to write and read data from the db layer.
OR should I delegate it to the individual class object. For example if I invoke city.save() (city is a class), then the city class will handle the saving of that city object's data into the database.
Excuse my ignorance but i have a java background and therefore trying to understand what is the best design principle for data management when using php.