Using PDO for Data Management
Posted
by
edorahg
on Programmers
See other posts from Programmers
or by edorahg
Published on 2012-06-03T15:29:39Z
Indexed on
2012/06/05
4:48 UTC
Read the original article
Hit count: 126
php
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.
© Programmers or respective owner