From: Ingendorf, P. <PIn...@ai...> - 2000-05-21 16:23:10
|
Here is the first run for the full database abstraction it seems like very few functions are used in php helpdesk which made this a bit easier. I will get a little more with the "program" a bit later and get into the CVS and stuff but right now I've very busy and this is just a quick hack that will enable the project to switch over to this type format while maintaining current functionality until I can put some real time into this and give it real value. includes:connect.inc.php3 <?php if ( ($db_type == "mysql" ) { $db_link = @mysql_connect("$db_server", "$db_username", "$db_password");; if (!$db_link) { print "<B>ERROR:</B> <I>Can not connect to database</I>\n"; echo mysql_errno().": ".mysql_error()."<BR>"; exit; } @mysql_select_db($db_db, $db_link) or die ("Could not select database $db_db. Has it been installed?"); } elseif ( $db_type == "postgres" ) { echo "Comming soon Less than Weeks we hope"; } ?> includes:db_inc.php3 <?php // db abstraction lib currently abstracts only the functions that are used and not any that may be used in the future function db_result ($query="",$db_link="") { if ( $db_type == "mysql" ) { $db_result = @mysql_query($query,$db_link); if ( !($db_result) ) { echo mysql_errno().": ".mysql_error()."<BR>"; } else { return $db_result; } } elseif ( $db_type == "postgres" ) { echo "Comming soon Less than Weeks we hope"; } // This one may cause some problems down the line as the postgres implimentation seems to require a start point and mysql fetch row funtion just steps through it sequentialy each time function db_fetch_row ( $db_result ) { if ( $db_type == "mysql" ) { $db_fetch_row = @mysql_fetch_row($db_result); if ( !($db_fetch_row) ) { echo mysql_errno().": ".mysql_error()."<BR>"; } else { return $db_fetch_row; } } elseif ( $db_type == "postgres" ) { echo "Comming soon Less than Weeks we hope"; } ?> |