All pastes #68167 Raw Edit

diogo86

public php v1 · immutable
#68167 ·published 2006-06-21 03:55 UTC
rendered paste body
function myquery($sql, $args = array()){	$strpos = 0;	$strlen = 0;	while( !empty($args) && ($strpos = strpos($sql,'?',$strpos+$strlen)) !== false ){		$str = mysql_real_escape_string(array_shift($args));		$strlen = strlen($str) + 2; // 2 das ' antes e depois da str		$sql = substr_replace($sql, "'" . $str . "'", $strpos,1);	}	return mysql_query($sql);}myquery("INSERT INTO mytable values (?, ?, ?)", array("field1", "field2", 3));