Hi again
As I'm developing my site, i've come across a problem with the database use.
While developing it I only have mySQL, but the final server has msSQL. I
was thinking about using all my own functions (ie sql_query), which would be
a function in an include file which would either call mysql_query or
mssql_query depending on the server (i'd have two different include files
for this).
Has anyone done this before, do you know of any drawbacks, or are there any
problems i'm likely to come across? I'm hoping speed won't be an issue,
since its just calling a function which does the exact same job.
Heres what I had in mind:
####### in the main file #########
$query = "SELECT * FROM .....";
$result = sql_query($quer y);
$num = sql_num_rows($r esult);
############### ############
##### include file, for mysql ######
function sql_query($sqlq uery)
{
$result = mysql_query($sq lquery);
return $result;
}
function sql_num_rows($s qlresult)
{
$num = mysql_num_rows( $sqlresult);
return $num;
}
############### ###############
I've just made this up off the top of my head so there may be the odd
mistake, but does the idea look right? I'd have another very similar file
for mssql_.....
David
As I'm developing my site, i've come across a problem with the database use.
While developing it I only have mySQL, but the final server has msSQL. I
was thinking about using all my own functions (ie sql_query), which would be
a function in an include file which would either call mysql_query or
mssql_query depending on the server (i'd have two different include files
for this).
Has anyone done this before, do you know of any drawbacks, or are there any
problems i'm likely to come across? I'm hoping speed won't be an issue,
since its just calling a function which does the exact same job.
Heres what I had in mind:
####### in the main file #########
$query = "SELECT * FROM .....";
$result = sql_query($quer y);
$num = sql_num_rows($r esult);
############### ############
##### include file, for mysql ######
function sql_query($sqlq uery)
{
$result = mysql_query($sq lquery);
return $result;
}
function sql_num_rows($s qlresult)
{
$num = mysql_num_rows( $sqlresult);
return $num;
}
############### ###############
I've just made this up off the top of my head so there may be the odd
mistake, but does the idea look right? I'd have another very similar file
for mssql_.....
David
Comment