| 
	
 | 
 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] 
 |