Data source abstraction

7/12/2009

In most cases, models within an application tend to be just classes extending a base class which acts as an abstraction layer to a database engine, like mysql.

I recently found myself in a situation where this way of thinking made almost no sense.

I was building the most basic user registration / authentication system:

  • User registers
  • User authenticates successfully
  • User data gets stored in session

I then realised that the first and thirds steps are exactly the same step, but with a different backend so I started thinking about it …

Why are models a bridge between PHP and MySQL (or any other language / database server)?

Wouldn’t it be nicer, more powerful to have writer / reader objects, that can interact with a multitude of engines that can store data? Like cookies, sessions, databases, xml, soap, etc?

Data source abstraction

No comments yet.

Write a comment: