View Full Version : Easiest way to use multipule types of databases
marcus1060
09-21-2006, 01:02 AM
I'm currently updating one of my scripts to work with postgre sql, rather then just mysql.
And I was wondering, whats the easiest way to make a PHP script work with more then one type of database?
marek_mar
09-21-2006, 01:13 AM
Probably by using some sort of Abstraction Layer -> Something that will give you the same set of functions for accessing databases. PDO (http://www.php.net/pdo) is an example. You could also test my own DBAL (http://www.codingforums.com/showpost.php?p=485560&postcount=7) (I'd be thankful).
Beagle
09-21-2006, 06:06 PM
I would HIGHLY recommend PEAR::MDB2
Check pear.php.net and search for MDB2. It's a thorough and relatively thin abstraction layer.
marcus1060
09-21-2006, 08:56 PM
Well I'm looking for something that doesn't rely on the user who downloads the script from his site to need anything extra, just chooses the database type he wants.
Beagle
09-22-2006, 02:41 PM
If you intend on deploying a script that interfaces with their database, you either need to right your own abstraction layer that calls all of the different functions for every possible database, or you need to leverage some code that has already done it for you.
If you want to support multiple databases, you're just better off saying "this script requires PEAR::MDB2" or "this script only support mysql".
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.