Hi Kenneth,
Thank you very much for your thoughts.
The simplest method I have found sofar is the following (for
mysql_connect):
function sql_connect()
{
$p = func_get_args();
return ( call_user_func_array('mysql_connect', $p) );
}
Anybody got any other ideas?
You might define a handful of classes, one for each db platform, all
of which have the same functions (*query, *fetch_array etc). That is
a nice "oopy" way to do things.
That would be a nice thing to do. No problem with OO, but it is just that I
am looking for a quick (and non-OO) way to do this. For my bigger projects
I usually have some stub-objects to communicate with the database.
If you have no great love of object-orientation, you just have a file
with lots of switches in it. Which, IHMO, is much easier to maintain:
[code snipped]
Its the same typing in either case, but in the latter you have
everything in one place where you can see it.
Its not the problem with the conditional includes that I am having, in fact,
I could still apply the switch approach using the above method (in fact, the
switches are there, but just one level higher - this also has the advantage
that it needs to be called only once for each script, and not on each
invocation of a database function). If anyone is interested, it is like
this:
switch ( DBTYPE )
{
case ( 'mysql' ): include_once('db_mysql.inc.php'); break;
case ( 'mssql' ): include_once('db_mssql.inc.php'); break;
}
(in fact, I have thought about making one statement:
include_once('db_'.DBTYPE.'.inc.php');
but this has the advantage that you see which dbs are supported)
What I am having problems with is easily/efficiently setting up a function
alias.
But thanks again!
--
Martijn
http://www.sereneconcepts.nl