Pear MDB2 class and raiserror exceptions in MSSQL

Posted by drholzmichl on Stack Overflow See other posts from Stack Overflow or by drholzmichl
Published on 2010-05-04T09:51:20Z Indexed on 2010/05/04 9:58 UTC
Read the original article Hit count: 375

Filed under:
|
|
|

Hi, in MSSQL it's possible to raise an error with raiserror(). I want to use a severity, which doesn't interrupt the connection. This error is raised in a stored procedure. In SQL Management Studio all is fine and I get my error code when executing this SP. But when trying to execute this SP via MDB2 in PHP5 this doesn't work. All I get is an empty array.

MDB2 object is created via (including needed options):

$db =& MDB2::connect($dsn);
$db->setFetchMode(MDB2_FETCHMODE_ASSOC);
$db->setOption('portability',MDB2_PORTABILITY_ALL ^ MDB2_PORTABILITY_EMPTY_TO_NULL);

The following works (I get a PEAR error):

$db->query("RAISERROR('test',11,0);");

But when calling a stored procedure which raises this error via

$db->query("EXEC sp_raise_error");

there is not output. What's wrong?

© Stack Overflow or respective owner

Related posts about pear

Related posts about php