What's a good way to encapsulate data access with PHP/MySQL? What's a good way to encapsulate data access with PHP/MySQL? database database

What's a good way to encapsulate data access with PHP/MySQL?


ActiveRecord seems to be the state of the art at the moment. I can't recommend any good PHP frameworks for that though. I tried Propel which, while nice, is not easy to set up (especially on a host that you can't install anything on).

Ultimately, I rolled my own ORM/ActiveRecord framework, which is not too much work and very instructive. I'm sure other people can recommend good PHP frameworks.


Take a look at the Zend Framework, specifically Zend_Db. It has a Database Abstraction layer that doesn't require anything other than the MySQLi extension to be installed and isn't a full-blown ORM model.


Maybe Doctrine would do the job? It seems to be inspired by Hibernate.