简体   繁体   中英

PHP PDO running MSSQL Stored Procedure

I use PDO to run MSSQL stored procedures a lot but I occasionally run into issues where the store procedure does not run correct.

Currently, I have a rather complex stored procedure that includes various inserts into temp tables and a nested loop statement. When I exectute the stored procedure from them SQL Manager it runs fine. It takes about 1.5 minutes to run but it completes without issue.

The problem is when I run it from PHP like this:

$q = $dbh->prepare('exec sp_mysp');
$q->execute();

I have checked the $q->errorInfo(); and there are no errors but the procedure does not complete. It looks like it's dumping out in the middle of the nested loop in the stored procedure.

Are there any limitations to what a stored procedure can do when it's being called from PHP with PDO? Also, is there a good way to debug this because I am stuck.

Any help with this would be great.

Thanks!

I had the same issue where my Stored Proc executed fine through SQL management studios but not when I called the EXECUTE through PHP using PDO. I was passing no params etc.

For what ever reason it was the fact that I was INSERTing values into a Temp table - as soon as I replaced the temp table with an actual table the Stored Proc executed fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM