Reply to Re: Abstracting a database class

Your name:

Reply:


Posted by Chung Leong on 01/04/06 03:59

Full Decent wrote:
> I like this idea and the possibility of running "DB queries" against a
> real DB, the filesystem, or the network. Do you know of existing
> classes that provide this level of abstraction beyond ADODB?

It's just a matter of separating the concerns of your code. Doesn't
really require special logic. For example, say you need to retrieve a
article from the database, instead of running the query in the
application code itself, call a function to do it:

$message = GetMessageById($id);

or

$message = GetMessageByTitle($title);

or

$messages = GetMessagesByDate($start, $end);

If you want to get fancy, use a class factory

$messages = $message_factory->Load($criteria, $offset, $length);

There are many ways to do this. The bottomline is to isolate the data
save/retrieval code, so that you can swap in a different mechanism by
simply including a different file.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация