php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63638 Cannot connect to SQL Server 2008 with PDO dblib
Submitted: 2012-11-28 21:09 UTC Modified: 2013-06-01 06:01 UTC
Votes:18
Avg. Score:4.5 ± 0.8
Reproduced:18 of 18 (100.0%)
Same Version:16 (88.9%)
Same OS:7 (38.9%)
From: pmeunier at cybergeneration dot com Assigned: laruence (profile)
Status: Closed Package: PDO related
PHP Version: 5.4.9 OS: Linux Slackware 13
Private report: No CVE-ID: None
 [2012-11-28 21:09 UTC] pmeunier at cybergeneration dot com
Description:
------------
We are relying on PDO_DBLIB to connect to our SQL Server 2008 Server in PHP, 
hosted on a Linux platform. We were running PHP 5.4.7 and everything was fine. 
When we upgraded to 5.4.9, all connections to SQL Server were failing with the 
following error : Warning: PDO::__construct(): Called dbsetopt with parameter 3 
NULL (severity 11). We tried with different logins to be sure that it was not a 
permission issue, but the bug also occurs when trying to log with 'sa'.

Test script:
---------------
$connection = new PDO('dblib:host=myServerHost;dbname=MyDatabase', 'username', 'pass');

Expected result:
----------------
We expect no warnings to be thrown and connection to SQL Server to work

Actual result:
--------------
A warning is thrown : Warning: PDO::__construct(): Called dbsetopt with parameter 
3 NULL (severity 11)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-11-28 21:43 UTC] pmeunier at cybergeneration dot com
We made a compare between the /ext/pdo_dblib/ php 5.4.7 and php 5.4.9 and found 
only one file was changed. Line 318 in dblib_driver.c went from :

// In PHP 5.4.7
DBSETOPT(H->link, DBQUOTEDIDENT, 1);

To :

// In PHP 5.4.9
DBSETOPT(H->link, DBQUOTEDIDENT, NULL);

For fun, we tried to revert to passing 1 for the last parameter... and guess 
what ? It worked. Since we don't actually understand what this function makes, 
and why the parameter was changed, we don't find this solution very clean, 
unless it is eventually confirmed by a PHP developper.
 [2012-12-05 16:49 UTC] f dot marquis at of2m dot fr
same problem here, but only from time to time (not all connections are failing 
like with pmeunier)

seems related to #63258
 [2012-12-07 16:37 UTC] wdmeldon at gmail dot com
I've tested this in SQL Server 2012, 2008 and 2005 with similar results.  The 
warnings do not always manifest however.  I've noticed returning output will 
prevent the warning as will calling other functions, but it's a crap shoot. 

The connection seems to be fine and the data returned is as well, so more annoying 
than anything else.

Running Ubuntu Server 12.04 with PHP 5.4.9.
 [2013-01-19 03:14 UTC] ssufficool@php.net
Looks like a Microsoft DBLIB versus FreeTDS issue. MS DBLIB requires the 
parameter to be NULL (per MSDN, possibly incorrect docs) while FreeTDS does not 
like the NULL parameter, thus I guess why I used "1" originally.

The patch from 1 to NULL should be reverted.
 [2013-01-19 03:14 UTC] ssufficool@php.net
-Assigned To: +Assigned To: laruence
 [2013-03-20 18:43 UTC] jwatson at fh dot org
A pull request was submitted with this patch. Please see the link below.

https://github.com/php/php-src/pull/306
 [2013-03-20 19:01 UTC] jwatson at fh dot org
A second pull request was submitted to merge to the PHP-5.4.13 branch, which is 
the latest branch for PHP 5.4. The original pull request above was for master.

https://github.com/php/php-src/pull/308
 [2013-06-01 05:58 UTC] ssufficool@php.net
Automatic comment on behalf of ssufficool
Revision: http://git.php.net/?p=php-src.git;a=commit;h=0e2bcf3373d914a215784c041a2a4c3b6afc2034
Log: FIX BUG #64338, #64808, #63638
 [2013-06-01 06:01 UTC] ssufficool@php.net
-Status: Assigned +Status: Closed
 [2013-06-01 06:01 UTC] ssufficool@php.net
The fix for this bug has been committed.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.


 [2013-06-04 03:40 UTC] ssufficool@php.net
Automatic comment on behalf of ssufficool
Revision: http://git.php.net/?p=php-src.git;a=commit;h=d8f938c78478c211dc3b5609e9f37d2e2c47896f
Log: FIX BUG #55647, #60512, #60512, #61900, #64338, #64808, #63638
 [2013-06-04 05:03 UTC] stas@php.net
Automatic comment on behalf of ssufficool
Revision: http://git.php.net/?p=php-src.git;a=commit;h=d8f938c78478c211dc3b5609e9f37d2e2c47896f
Log: FIX BUG #55647, #60512, #60512, #61900, #64338, #64808, #63638
 [2013-11-17 09:31 UTC] laruence@php.net
Automatic comment on behalf of ssufficool
Revision: http://git.php.net/?p=php-src.git;a=commit;h=d8f938c78478c211dc3b5609e9f37d2e2c47896f
Log: FIX BUG #55647, #60512, #60512, #61900, #64338, #64808, #63638
 [2013-11-17 09:31 UTC] laruence@php.net
Automatic comment on behalf of ssufficool
Revision: http://git.php.net/?p=php-src.git;a=commit;h=0e2bcf3373d914a215784c041a2a4c3b6afc2034
Log: FIX BUG #64338, #64808, #63638
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 06:01:30 2024 UTC