Skip to content
Advertisement

PHP get return value of stored procedure

I have pleasure to work with legacy PHP application using SQL Server via PDO.

How in PHP can I retrieve return value of stored procedure which is using RETURN statement as output channel?

Example procedure

JavaScript

If possible, I would prefer to not modify procedure.


I am aware that there are similar questions, but they don’t cover this case

Advertisement

Answer

Execute stored procedure like this: "exec ?=mleko_test(?)".

Working example:

JavaScript

Notes:

Tested with PHP 7.1.12 and PHP Driver for SQL Server (pdo_sqlsrv version 4.3.0+9904).

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement