All pastes #516920 Raw Edit

Untitled

public php v1 · immutable
#516920 ·published 2007-05-28 22:05 UTC
rendered paste body
	/**	 * Update userinformation	 *	 * @params array $args	 * @params array $fields	 */	function update ($id, $args, $fields, $table = 'users') {		$update = '';		$c = count($fields) - 1;		$x = 0;		foreach($fields as $key):			if(isset($args[$key])):				$update .= "$key = '{$args[$key]}'";								if($x != $c)					$update .= ', ';				++$x;			endif;		endforeach;			if($table == 'users'):			if(isset($args['admin']) && $args['admin'] == 1)				if(!$this->isAdmin($id))					$this->makeAdmin($id);						if(isset($args['admin']) && $args['admin'] == 0)				if($this->isAdmin($id))					$this->revokeAdmin($id);		endif;		$this->db->query("update $table set $update where id = $id");	}