- array_shift: documentation ( source)
- implode: documentation ( source)
- sprintf: documentation ( source)
<?php
function callStoredProc( $storedProc )
{
$args = func_get_args();
$storedProc = array_shift( $args );
foreach ( $args as $i => $arg)
$args[$i] = "'" . mysql_real_escape_string( $arg ) . "'";
$argStr = implode( ',', $args );
echo sprintf(
'call %s( %s )',
$storedProc,
implode( ',', $args )
);
}
callStoredProc( 'something', 1, 'a', 'b\'' );