P
phpCodeHead
I am trying to write a function that will allow me to call any MySQL
stored procedure and pass any array of values as parameters to pass to
that stored procedure.
So, far I have in my function:
$sql = "CALL $proc_name('" . implode("', '", $params) . "');";
Which is called like:
return callProcedure('someStoredProcedure', $params);
And is working fine, it generates an SQL statment like:
CALL someStoredProcedure('param1', 'param2', '@ID');
PROBLEM IS, it only works fine if all params are strings.
I am trying to come up with a "hack" that will NOT put single-quotes
on params that are integers or params that are specifiying OUT
arguments (i.e. the @ID should not be in quotes from what I'm reading
anyway..)
I'm new to working with MySQL Stored Procedures within PHP and would
like to have this generic function to make it easy to make calls to my
stored procedures from object's methods.
Such as:
private function insertTransaction($userid = null, $sessionid = null)
{
$params = array($userid, $sessionid, "@ID");
return callProcedure('insert_lmsTransaction',
$params);
}
Thanks for any inputs or help with heading me into the right
direction. I thought this would be simple, butt......
stored procedure and pass any array of values as parameters to pass to
that stored procedure.
So, far I have in my function:
$sql = "CALL $proc_name('" . implode("', '", $params) . "');";
Which is called like:
return callProcedure('someStoredProcedure', $params);
And is working fine, it generates an SQL statment like:
CALL someStoredProcedure('param1', 'param2', '@ID');
PROBLEM IS, it only works fine if all params are strings.
I am trying to come up with a "hack" that will NOT put single-quotes
on params that are integers or params that are specifiying OUT
arguments (i.e. the @ID should not be in quotes from what I'm reading
anyway..)
I'm new to working with MySQL Stored Procedures within PHP and would
like to have this generic function to make it easy to make calls to my
stored procedures from object's methods.
Such as:
private function insertTransaction($userid = null, $sessionid = null)
{
$params = array($userid, $sessionid, "@ID");
return callProcedure('insert_lmsTransaction',
$params);
}
Thanks for any inputs or help with heading me into the right
direction. I thought this would be simple, butt......