diogo86
public php v1 · immutablefunction 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));