All pastes #634921 Raw Edit

dbfunctions

public php v1 · immutable
#634921 ·published 2007-07-26 19:07 UTC
rendered paste body
function dbConnect() { //opens db connection		global $conn;	$conn = @mysql_connect($GLOBALS['DB']['dbhost'],$GLOBALS['DB']['dbuser'],$GLOBALS['DB']['dbpass']) or trigger_error("SQL", E_USER_ERROR);	@mysql_select_db($GLOBALS['DB']['database'],$conn) or trigger_error("SQL", E_USER_ERROR); //try to connect to db}function dbClose() { //closes db connection		@mysql_close($GLOBALS['conn']); //Close connection}function dbSelect($strQuery, &$bTrigger, &$aArray) {		global $strQry;	$strQry = $strQuery;	if ($strQry) { //if query string exists then continue				dbConnect();		$SearchQuery = @mysql_query($strQry,$GLOBALS['conn']) or trigger_error("SQL", E_USER_ERROR);		if (@mysql_num_rows($SearchQuery) == 0) {					   	$bTrigger = False;		}		else {						$bTrigger = True;			while($row = @mysql_fetch_array($SearchQuery)) {								$aArray[] = $row;			}		}		dbClose();	}	else $bTrigger = false;}function dbGeneral($strQuery, $srcTable, &$lastID) {		global $strQry;	$strQry = $strQuery;	if ($strQry) { //if query string exists then continue				dbConnect();		$UpdateQuery = mysql_query($strQry,$GLOBALS['conn']) or trigger_error("SQL", E_USER_ERROR);		if ($srcTable) $lastID = mysql_insert_id();		dbClose();	}}