Skip to content Skip to sidebar Skip to footer

Php Pdo (mssql) Can Not Get Ouput Parameters

I'm trying to get OUTPUT using bindParam (PHP PDO). The PHP PDO library is the FreeTDS for MS SQL driver. Whatever I do, I can't seem to get the 'OUTPUT' in the the bound params as

Solution 1:

AFAIK, the FreeTDS driver does not support OUTPUT parameters. I remember this from when my team was doing our assessment.

Here's why it doesn't work: http://www.freetds.org/faq.html#ms.output.parameters

EDIT: Here's a reference from pyodbc (which also runs on FreeTDS), so the same applies: https://code.google.com/p/pyodbc/wiki/StoredProcedures

To quote: "Results: Since we can't use output parameters at this point, you'll need to return results in a result set. Usually this means just ending your stored procedure with a SELECT statement."

You'll need to use a SELECT instead.

Solution 2:

Your stored procedure is assigning the parameters, but not returning them.

BEGINSET@error_num =99SET@error_msg ='Error! Oh my gosh!'SELECT@error_num, @error_msg;  --add this lineEND
GO

Post a Comment for "Php Pdo (mssql) Can Not Get Ouput Parameters"