Re: database absraction layer

From: Date: Tue, 07 May 2002 09:13:56 +0000
Subject: Re: database absraction layer
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-19006@lists.php.net to get a copy of this message
Adi wrote:
dear all, I'm writing database abstraction layer class (like adoDB but much simpler). What I want to do that it will provide single access function for different type of database. Currently, it will only support mySQL and PostgreSQL.. but I just don't know how to do this with better approach.
Usually you writer a driver class for each database that you want to support. Then you choose the appropriate class to access the database you want. You may want to look at Metabase database abstraction package to learn how to do that: http://www.phpclasses.org/browse.html/package/20.html Regards, Manuel Lemos
code snippet.. .. function connect(){ if($this->type == "mysql"){ $this->conid = mysql_connect($this->host,$this->user,$this->pass); } elseif($this->type == "pgsql")){ $this->conid = pg_connect($this->host $this->port $this->db $this->user $this->pass); } else { echo ("database type $this->type not supported"); } } .. any idea of doing such of function alias/wrapper? any help appreciated thanks _______________ adi.aroundbali.com
-- Regards, Manuel Lemos

« previous php.db (#19006) next »