I have a stored procedure that is returning its result using a transact print
statement to return it's result.
Until now I used the php_mssql
extension and its mssql_get_last_message()
function to get the returned text.
As PHP has dropped the support for the mssql extension, I decided to fall back to the php_odbc
extension.
The problem I face is that I cannot capture the info using odbc_errormsg()
. Is there a way to retrieve the print message using PHP and ODBC ?
I found some interesting questions dealing with the subject of print
and odbc
, but none related to PHP.
PHP code with mssql (works):
$query = "exec dbo.PdaBLCreer 12345";
$res = mssql_query($query);
$message = mssql_get_last_message();
PHP code with odbc (does not work, $message is always empty):
$query = "exec dbo.PdaBLCreer 12345";
$res = odbc_exec($connection, $query);
$message = odbc_errormsg($connection);
T-SQL stored procedure
CREATE PROCEDURE dbo.PdaBLCreer
@iArgument int
AS
BEGIN
...
PRINT @vNr
RETURN @vNr
END