What is the best PHP DAL (data abstraction layer) so far developed under any open source project which we could re-use with good faith?
I am finding it hard to choose a DAL for my application that sufficiently supports abstraction to most common databases systems (MySQL, PostgreSQL, MSSQL, Oracle, etc) and is:
Some of the libararies to consider:
Please don't consider:
What Is a Database Abstraction Layer? As the name suggests, a database abstraction layer is a layer which sits between your application and the underlying database. You'll use a database abstraction layer to interact with your database.
The three formal abstraction layers: User model: An informal representation of how the user describes the database. Logical model: More formal, with more detail and often rendered as an entity relationship model (ERM). Physical model: More detail added such as indexing and data types.
The database design goes through three levels of abstraction as we move from user requirements to DBMS implementation.
If you can do with PHP 5.3, I would highly recommend Doctrine DAL, it's built on top of PDO, so you get the same performance plus a great API.
Update: If Doctrine is not good, you can try MDB2. It has drivers for most of the popular RDBMS, a robust API, great docs and a huge user base:
I have been using Zend_Db for my web application for the past 1 year. I think, Zend Framework is the best by far.
Zend was started by folks who were the core contributors of PHP.(1)
widely tested
Yes. It is used by thousands of projects and has a active community of developers.
has good interface (readable method names ,good parameter passing strategy)
Yes. All Components can be easily customized to your needs. Every component in Zend is loosely coupled, meaning you can use any component without any dependency on any other component in the framework.
speed
Yes. Zend_Db using PDO, by default.
lightweight
Yes
providing cache (e.g integrates with memcache or supports a good caching mechanism)
Zend has an extensive caching system.
open-source license
Yes
To access a DB table, all you have to do, is create a class for it by setting the table name and its primary key as its fields.
class User extends Zend_Db_Table { protected $_name = "users"; //tablename protected $_primary = "user_key"; //primary key column function addNewUser($name,$age,$email) { //Validate input and add Logic to add a new user //Methods are available to insert data like $this->insert($data) // where $data is an array of column names and values // Check links below for documentation } }
This is called a model. In this class, you can create all the methods related to 'User' entity like adding a new user, editing user etc.
In your application code, you can use this as,
$u = new User(); $u->addNewUser('Name','Age','email');
Must Read this - http://framework.zend.com/manual/en/zend.db.table.html
More reference here. Check this relation question for more information
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With