Edit report at https://bugs.php.net/bug.php?id=64338&edit=1

 ID:                 64338
 Comment by:         mah at everybody dot org
 Reported by:        mah at everybody dot org
 Summary:            pdo_dblib can't connect to Azure SQL
 Status:             Open
 Type:               Bug
 Package:            MSSQL related
 Operating System:   any
 PHP Version:        5.5.0alpha5
 Block user comment: N
 Private report:     N

 New Comment:

Originally reported to Debian: http://bugs.debian.org/702079


Previous Comments:
------------------------------------------------------------------------
[2013-03-02 15:29:43] mah at everybody dot org

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 this bug report at https://bugs.php.net/bug.php?id=64338&edit=1

Reply via email to