All pastes #923830 Raw Edit

Stuff

public text v1 · immutable
#923830 ·published 2008-02-29 21:55 UTC
rendered paste body
	function DBS($table, $select, $where="") {
		global $db;
		return mysql_query("SELECT $select FROM $table $where", $db) or die(mysql_error());
	}
	
	function DBU($table, $array, $where="") {
		global $db;
		$updates = array();
		foreach($array as $key => $val) {
			$updates[] = "$key = ‘$val’";
		}
		$updates = implode(", ", $updates);
		return mysql_query("UPDATE $table $updates $where", $db) or die(mysql_error());
	}
	
	function DBI($table, $array) {
		$columns = join(", ", array_keys($array));
		$values = "‘" . join("‘, ‘", $array) . "‘";
		return mysql_query("INSERT INTO $table ($columns) VALUES ($values)", $db) or die(mysql_error());
	
	}
	
	function DBD($table, $where="") {
		global $db;
		return mysql_query("DELETE FROM $table $where", $db) or die(mysql_error());
	}