In PHP, what is the best practice for laying out the responsibilities of a Db Abstraction Layer?
Is OOP a good idea in terms of performance? How much should be generic object code, and how much should be very specific functions?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In most applications I have written, there are generally two different types of data access. One is for transactional operations: retrieving specific objects from the datastore, modifying them and saving them back. I’ve found a solid ORM to be the best solution here. Don’t try writing your own (as interesting as it might be.)
The other common type of data access is for reporting. ORMs aren’t the best solution here, which is why I usually go with a scheme that uses custom SQL queries. Plain ol’ PDO works well here. You can create a special value object just for that report and have the PDO query fetch the values into the object. Reports need to be fast and building them using an ORM layer is usually just too slow and cumbersome.