Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems: MDB2 with Stored Procedures on MSSQL

Status
Not open for further replies.

MikeBronner

Programmer
May 9, 2001
756
US
Hi All,

For the life of me, I can't figure out how to successfully execute stored procedures in PHP (on IIS) in MSSQL using MDB2.

I have the following code:
Code:
$db = MDB2::connect([...]);
$db->loadModule("Function");
$r_resultset = $db->function->executeStoredProc("[stored proc name]", [parameter array]);
if (MDB2::isError($r_resultset)) {print($r_resultset->getMessage());}
This returns the following output:
Object id #6
That doesn't seem like a very good error message to me. I get the same 'error' when trying to do this using $db->query("EXECUTE [stored proc name] [list of parameters"), just with a lower number (Object id #4), and the same trying $db->exec([...]) (Object id #5).

I'm truly stumped. One of the problems I have found is that MDB2 does not provide adequate documentation and examples, and there doesn't seem to be anything regarding executeStoredProc when searching in Google. I appreciate any help and advice! :)

Thanks guys!
 
Using getDebugInfo() instead of getMessage() it now shows the following error:
_doQuery: Could not execute statement[Native code: 170] [Native message: Line 1: Incorrect syntax near ','.]

Is the MSSQL driver for MDB2 faulty? How can I debug what it really queries?

Thanks!

Take Care,
Mike
 
I managed to resolve the issue. After some further inspection of what MDB2 was doing with the parameter array, I noticed that it wasn't substituting empty array elements with NULL, so I had to compensate for that by looping through my parameter array and inserting the keyword NULL into any empty array element. As soon as I did that, I got it working. :)

Take Care,
Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top