From:             
Operating system: Ubuntu 12.04
PHP version:      5.3.11
Package:          PDO related
Bug Type:         Bug
Bug description:Cannot use PDO (dblib) and mssql_ (FreeTDS) in the same script

Description:
------------
When using PDO (dblib) and mssql_ (FreeTDS) in the same script, PDO will
not 
throw any Exceptions.

This is apparently due to the calls to 'dberrhandle' in the FreeTDS
library:

https://github.com/php/php-src/blob/master/ext/mssql/php_mssql.c#L598
https://github.com/php/php-src/blob/master/ext/pdo_dblib/pdo_dblib.c#L205


Regardless of the order in the PHP Script, php_mssql is executed last,
which 
will replace any error handler function that pdo_dblib has set.

This also seems to be the case when 'forcing' the use of multiple
connections.

Whilst using both functions is a silly thing to do, we are migrating a 9
year 
old project over to PDO in a number of phases.

Test script:
---------------
<?php
/*
 * Setup an MSSQL connection (FreeTDS library)
 * It does not matter if this is executed before or after the PDO object
is
 * instantiated.
 */
$mssql = mssql_connect('server', 'user', 'pass');

$pdo = new PDO('dblib:host=server;dbname=db', 'user', 'pass');
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

try
{
    $pdo->query('INSERT INTO incorrecttable (abc) VALUES (123)');
    echo "Exception not thrown\n";
}
catch(\PDOException $exception)
{
    echo "Exception caught\n";
}

Expected result:
----------------
Exception caught

Actual result:
--------------
Warning: PDO::query(): message: Invalid object name 'incorrecttable'.
(severity 
16) in /tmp/php-test/pdotest.php on line 15

Call Stack:
    0.0001     631912   1. {main}() /tmp/php-test/pdotest.php:0
    0.0557     633632   2. PDO->query() /tmp/php-test/pdotest.php:15


Warning: PDO::query(): General SQL Server error: Check messages from the
SQL 
Server (severity 16) in /tmp/php-test/pdotest.php on line 15

Call Stack:
    0.0001     631912   1. {main}() /tmp/php-test/pdotest.php:0
    0.0557     633632   2. PDO->query() /tmp/php-test/pdotest.php:15

Exception not thrown

-- 
Edit bug report at https://bugs.php.net/bug.php?id=61900&edit=1
-- 
Try a snapshot (PHP 5.4):            
https://bugs.php.net/fix.php?id=61900&r=trysnapshot54
Try a snapshot (PHP 5.3):            
https://bugs.php.net/fix.php?id=61900&r=trysnapshot53
Try a snapshot (trunk):              
https://bugs.php.net/fix.php?id=61900&r=trysnapshottrunk
Fixed in SVN:                        
https://bugs.php.net/fix.php?id=61900&r=fixed
Fixed in SVN and need be documented: 
https://bugs.php.net/fix.php?id=61900&r=needdocs
Fixed in release:                    
https://bugs.php.net/fix.php?id=61900&r=alreadyfixed
Need backtrace:                      
https://bugs.php.net/fix.php?id=61900&r=needtrace
Need Reproduce Script:               
https://bugs.php.net/fix.php?id=61900&r=needscript
Try newer version:                   
https://bugs.php.net/fix.php?id=61900&r=oldversion
Not developer issue:                 
https://bugs.php.net/fix.php?id=61900&r=support
Expected behavior:                   
https://bugs.php.net/fix.php?id=61900&r=notwrong
Not enough info:                     
https://bugs.php.net/fix.php?id=61900&r=notenoughinfo
Submitted twice:                     
https://bugs.php.net/fix.php?id=61900&r=submittedtwice
register_globals:                    
https://bugs.php.net/fix.php?id=61900&r=globals
PHP 4 support discontinued:          
https://bugs.php.net/fix.php?id=61900&r=php4
Daylight Savings:                    https://bugs.php.net/fix.php?id=61900&r=dst
IIS Stability:                       
https://bugs.php.net/fix.php?id=61900&r=isapi
Install GNU Sed:                     
https://bugs.php.net/fix.php?id=61900&r=gnused
Floating point limitations:          
https://bugs.php.net/fix.php?id=61900&r=float
No Zend Extensions:                  
https://bugs.php.net/fix.php?id=61900&r=nozend
MySQL Configuration Error:           
https://bugs.php.net/fix.php?id=61900&r=mysqlcfg

Reply via email to