Forum Moderators: coopster
To get this thing going I'll add a few things in here...
1) Newline representation on Windows is
\r\n where on Unix it is just \n (also different for Mac: \r). 2) Accounting for differences between databases (MSSQL and MySQL). A solution to this might be to use variable functions [php.net] for all the database functions (set in a config file).
For example:
if($db == 'mysql') {
$db_connect = 'mysql_connect';
....
}
else if($db == 'mssql') {
$db_connect = 'mssql_connect';
....
}
$link = $db_connect('localhost','username','password');
What do you have?
So if we assume the web app is aware of a $db_obj object and 3 wrapper functions db_connect, db_query, db_close then the db interface could be:
switch($db) {
case 'mssql':
require_once('ms_sql');
$db_obj = new ms_sql;
break;
case: 'mysql':
default:
require_once('my_sql');
$db_obj = new my_sql;
break;
}
and each of the dbase classes includes a set of wrappers for the web app with connect being one of them
$db_obj->connect('localhost','username','password');
and the link can be stored as a member var of the db class if ever needed by the higher layer,
$link = $db_obj->get_link();