From PHP: retrieve the value saved in MYSQL SPs OUT param
Posted: Wed Jan 23, 2008 9:50 am
Hi All,
I have created a simple stored proc. in MySQL that returns the number of rows fetched by a query.
CREATE PROCEDURE ROW_COUNT(tablenames VARCHAR(1000), querycmd VARCHAR(8000), OUT cnt INT)
The body contains a "SELECT count(*) INTO ........" kind of statement that saves the row count into the OUT variable cnt.
From Mysql command line, I can access this value using the stmt > select @cnt. Everything works fine.
From my php code, I call the proc as follows:
$call = mysqliObj->query("CALL ROW_COUNT(value for param1, value for param2, @out)");
After this, how do I retrieve the value contained in the @out.
I can use other mysqli routines like fetch_associative followed by some processing to get it. But is
there any simpler way. Also, I don't wan't to use stored function.
Please help. I have searched the web and forums quite a lot and haven't found the answer.
Thanks,
Deb
I have created a simple stored proc. in MySQL that returns the number of rows fetched by a query.
CREATE PROCEDURE ROW_COUNT(tablenames VARCHAR(1000), querycmd VARCHAR(8000), OUT cnt INT)
The body contains a "SELECT count(*) INTO ........" kind of statement that saves the row count into the OUT variable cnt.
From Mysql command line, I can access this value using the stmt > select @cnt. Everything works fine.
From my php code, I call the proc as follows:
$call = mysqliObj->query("CALL ROW_COUNT(value for param1, value for param2, @out)");
After this, how do I retrieve the value contained in the @out.
I can use other mysqli routines like fetch_associative followed by some processing to get it. But is
there any simpler way. Also, I don't wan't to use stored function.
Please help. I have searched the web and forums quite a lot and haven't found the answer.
Thanks,
Deb