0

in SQL Server 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?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
user332194
  • 11
  • 3

1 Answers1

2

Verify the returned result objects via

$res = $db->query(..)
if (MDB2::isError($res)) {
    echo $res->getMessage() . "\n" . $res->getUserInfo();
    die();
}

See http://pear.php.net/manual/en/package.database.mdb2.intro-fetch.php

cweiske
  • 30,033
  • 14
  • 133
  • 194