Location: PHPKode > projects > Switchport Map > switchportmap/libs/func.queryi.php
<?php
function queryi($mysqli,$sql,$type = 'assoc') {
	
	$valid = array(MYSQLI_ASSOC=>'assoc',MYSQLI_NUM=>'array',MYSQLI_BOTH=>'both','result'=>'result','count'=>'count','insert'=>'insert','update'=>'update');
	$invvalid = array_flip($valid);
	if(!in_array($type,$valid)) {
		return FALSE;
	}
	
	if(!$result = $mysqli->multi_query($sql)) {
		return array('error',$mysqli->errno, $mysqli->error,$sql);
	}
	
	$query = $mysqli->store_result();
	
	//if(!$query = $mysqli->store_result()) {
	//	return array('error',$mysqli->errno, $mysqli->error,$sql);
	//}
	
	/*if($type == 'result') {
		for($i=2;$i<func_num_args();$i++) {
			$n=base_convert($i+10,10,36);
			$$n = func_get_arg($i);
		}
		$b = (!isset($b))?0:$b;
		$rtn = $query->fetch_row();//($a,$b);
		return $rtn[
	} else*/if($type == 'count') {
		return $query->num_rows();
	} elseif($type == 'insert' OR $type == 'update') {
		return $query;
	} else {
		$rtn = array();
		while($r=$query->fetch_array()) { //mysql_fetch_array($query,$invvalid[$type])) {
			$rtn[]=$r;
		}
		//$query->free_result();
		return $rtn;
	}
}
?>
Return current item: Switchport Map