0

I encountered a problem when a PDO object in PHP stopped working properly in combination with an ODBC connection to a Sybase ASE 15.7 database. The problem occurred when changing the Sybase client on the server from version 15.0 to version 15.7.

The problem is that after changing the client, some SELECT statements do not return records using the fetchAll function. This problem only occurs if I have a custom function declared and I return the result using return in that function.

Example:


 function GetData($host,$user,$passwd) {
  $zaz = []; 
    try {    
        $options = [
           PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
           PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ,
         ];
$pdo = new PDO($host, $user, $passwd, $options);       
        $sqlTmp = 'SELECT * FROM xxx WHERE kzak=:kzak AND popzak=:popzak';
        $bindTmp = array(
            'kzak' => (int) 2327,
            'popzak' => 'letter'
        );
        $pdostmt = $pdo->prepare($sqlTmp);
        if ($pdostmt->execute($bindTmp) !== false) {
        //$zaz='TEST';
          $zaz = $pdostmt->fetchAll(PDO::FETCH_ASSOC);                               
          print_r($zaz); //here the variable with data is dumped
        }
    } catch (PDOException $e) {      
        echo 'error: ' . $e->getMessage();       
    } finally {
        return $zaz; //will not be performed
    }
 }

 $data = GetData($HOSTC,$USERC,$PASSWDC);
 var_dump($data);

If I put after print_r($zaz); the data is printed, but the return function is not filled. If I put $zaz='TEST'; and comment out the line with $zaz = $pdostmt->fetchAll(PDO::FETCH_ASSOC); , the return value is 'TEST'.

Another problem is that the Apache service stops and the event log shows:

ConsentKey=APPCRASH
AppName=Apache HTTP Server
ig[0].Name=Application Name
Sig[0].Value=httpd.exe
Sig[1].Name=Application Version
Sig[1].Value=2.4.55.0
Sig[2].Name=Application Timestamp
Sig[2].Value=63c44299
Sig[3].Name=Fault Module Name
Sig[3].Value=VCRUNTIME140.dll
Sig[4].Name=Fault Module Version
Sig[4].Value=14.0.24123.0
Sig[5].Name=Fault Module Timestamp
Sig[5].Value=574290ad
Sig[6].Name=Exception Code
Sig[6].Value=c0000005
Sig[7].Name=Exception Offset
Sig[7].Value=0000dd5b

and

ConsentKey=APPCRASH
AppName=ODBC Administrator
AppPath=C:\Windows\syswow64\odbcad32.exe
Sig[0].Name=Application Name
Sig[0].Value=odbcad32.exe
Sig[1].Name=Application Version
Sig[1].Value=10.0.20348.1
Sig[2].Name=Application Timestamp
Sig[2].Value=f4e4d789
Sig[3].Name=Fault Module Name
Sig[3].Value=MSVCR80.dll
Sig[4].Name=Fault Module Version
Sig[4].Value=8.0.50727.9680
Sig[5].Name=Fault Module Timestamp
Sig[5].Value=6090c909
Sig[6].Name=Exception Code
Sig[6].Value=c0000005
Sig[7].Name=Exception Offset
Sig[7].Value=00012339

Apache version is 2.4.55 and we tried PHP versions 5.6.9, 5.6.40 and 8.2.7.

Has anyone of you encountered this? Do you know the solution to the problem? Thank you

  • Is there an exception reported anywhere? Either on-screen, or in the PHP error log? Does the database driver itself do any logging? – ADyson Jun 22 '23 at 11:54
  • 1
    You should remove the try/catch. There's no reason for outputting an exception to the screen (to the user) since it's usually just gibberish for the user, and can also leak sensitive info. If you get an exception, own it and have a global exception handler for your app instead. – M. Eriksson Jun 22 '23 at 11:54
  • I have set error_log in php to a file, but it is empty. Apache error log is also empty. Only event log windows, there is recorded crashapp httpd.exe and odbcad32. If I run the script directly using php.exe test.php, the crashapp is not written to the event log. – user22107564 Jun 22 '23 at 12:19
  • try/catch I have now only in the sample test example. I do not show anything to the user in the live environment. – user22107564 Jun 22 '23 at 12:22

0 Answers0