PDO ODBC, one of several result sets causes php to crash

502 Views Asked by At

-Running PHP 5.6 on IIS 8.5 (Windows Server 2012 R2)

-Connecting to SQL Server 2008 R2 remotely via PDO, ODBC

-Issue isolated to one query, other queries function normally with expected results.

I am calling a stored procedure that returns eight result sets. I write each result set to a CSV. When I get to the third result set, php-cgi.exe crashes and I get a 500 error.

I have isolated the issue to this particular result set because if I skip the result set altogether using $stmt->nextRowset() everything works as expected.

    //execute sp, bind parameters year and period-defined above
    $StmtText = "{CALL PROCESS_PR (?, ?) }";
    $Stmt = $dbh->prepare($QueryText);
    $Stmt->bindParam(1, $PayYear, PDO::PARAM_INT);
    $Stmt->bindParam(2, $PayPeriod, PDO::PARAM_INT);
    $Stmt->execute();

    $file_out = fopen('c:\windows\temp\tmp_1.csv, 'w');
    $Result =  $Stmt->fetchAll(PDO::FETCH_NUM);
    foreach($Result as $row) { fputcsv($file_out,$row); }
    fclose($file_out);

    $Stmt->nextRowset();

    //this happens 8 times, fails on the third

I am not throwing any PHP errors, and advanced IIS logging doesn't suggest a whole lot. I am struggling to determine what is crashing PHP. I executed the stored procedure directly via SSMS and it executes successfully, and looking at the problematic result set, can't see anything out of the ordinary- no special characters, no long strings, etc.

I have also been down the road of confirming PHP memory limits are set appropriately, checking timeouts on both FastCGI and in php.ini, and verifying MVC++ 2012 is installed, both 32bit and 64bit.

Looking for any thoughts on how to track down php crashing on this one particular result set. Thanks much.

UPDATE: Laughing Vergil's answer below solved the issue. The problematic result set had two fields with datatype varchar(max). changing one of them to varchar(255) solved the problem.

0

There are 0 best solutions below