supporting multiple databases...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hiya.

I'm writing an application which needs to make SQL queries, and I'd like
to give it support for multiple database servers, starting with MySQL
and PostgreSQL.  I see that other folks have done this with a variety of
methods, and I can't see a clear winner.

Option 1 - Drop in a set of db-related functions as part of the install
procedure.  I.e. a file "db_func.php" is copied from "db_func.php-pg" or
"db_func.php-my" as part of the install procedure.  The functions
contained will return equivalent results.  This has the advantage of
leaving the installed application more streamlined, but it requires
better coordination between functions and things that call them; your
total number of db functions is multiplied by the number of databases
supported.

Option 2 - Select function behaviour based on a config variable.  That
is, the same database functions will run, but there can be if() or
switch() statements to control how the db is dealt with.  This keeps the
function list tighter, but it seems to make for less elegant and
probably less maintainable code.

Option 3 - Write relatively generic database functions, but control the
format of SELECTs and even the db connect functions called from config
variables.  This seems elegant on the surface, but make for highly
obtuse code.

Is there a preferred method of handling this issue, or does everybody
just roll their own?

-- 
  Paul Chvostek                                             <paul@xxxxx>
  it.canada                                            http://www.it.ca/

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux