Created
August 12, 2010 20:40
-
-
Save tomkrush/521684 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function query() | |
{ | |
$args = func_get_args(); | |
if ( $args > 0 ) | |
{ | |
$sql = array_shift($args); | |
$pos = 0; | |
foreach ($args as $val) | |
{ | |
$pos += strpos(substr($sql, $pos, strlen($sql)-$pos), '?'); | |
if ($pos !== false) { | |
$replacement = "'" . mysql_real_escape_string($val) . "'"; | |
$sql = substr_replace($sql, $replacement, $pos, strlen('?')); | |
$pos += strlen($replacement); | |
} | |
else | |
{ | |
break; | |
} | |
} | |
return mysql_query($sql); | |
} | |
return FALSE; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment