From:             mah at everybody dot org
Operating system: any
PHP version:      5.5.0alpha5
Package:          MSSQL related
Bug Type:         Bug
Bug description:pdo_dblib can't connect to Azure SQL

Description:
------------
The SQL database available on Azure apparently does not have the same
connection semantics as SQL Server.  “use DATABASE” is not possible —
it
returns an error saying that you should open a new connection if you
want a new database.

This is confusing when you are using the DBLIB connector because it is
the DBLIB connection code that does the “use”, not the developer's PHP
code.

The FreeTDS people recognized this a while back:

    About a year ago we added the DBSETLDBNAME macro as a way to set the
    dbname in the db-lib LOGINREC.  That sets the dbname in the login
    packet, obviating the need for "USE dbname".

    http://lists.ibiblio.org/pipermail/freetds/2012q4/028168.html

The attached patch makes use of DBSETLDBNAME and eliminates the USE.


Test script:
---------------
<?php

try {
    $server = "SERVER.database.windows.net:1433";
    $username = "USER@SERVER";
    $password = "PASSWORD";
    $dbname = "DBNAME";
    $mssql = new
PDO("dblib:host=$server;dbname=$dbname",$username,$password);
    echo "Success!\n";
}
catch ( PDOException $e ) {
   print( "Error connecting to SQL Server." );
   die(print_r($e));
}



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

Reply via email to