note 89741 modified in function.func-get-args by danbrown
| From: | danbrown@php.net | Date: | Fri, 20 Mar 2009 21:03:57 +0000 |
| Subject: | note 89741 modified in function.func-get-args by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-152237@lists.php.net to get a copy of this message | ||
sanitazes vars
<?php
function mysql_safe($q) {
$x = array_shift(func_get_args());
return vsprintf(preg_replace('/%([1-9]):(d|s)/','%$1$$2',$q),
array_map('mysql_escape_string',$x));
}
?>
example
<?php
$query = mysql_safe("select * from somewhere where mood = %2:s and some_id = %1:d order by %3:s
desc", $id, 'happy', $order);
?>
--was--
sanitazes vars
function mysql_safe($q) {
$x = array_shift(func_get_args());
return vsprintf(preg_replace('/%([1-9]):(d|s)/','%$1$$2',$q),
array_map('mysql_escape_string',$x));
}
example
$query = mysql_safe("select * from somewhere where mood = %2:s and some_id = %1:d order by %3:s
desc", $id, 'happy', $order)
http://php.net/manual/en/function.func-get-args.php