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

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

 New Comment:

btw, DBSETLDBNAME could be easily added in pdo_dblib_handle_factory 
(ext/pdo_dblib/dblib_driver.c).

Can you test it pls? if you could create a patch and test it, even better :)


Previous Comments:
------------------------------------------------------------------------
[2013-03-02 16:56:05] paj...@php.net

I suppose you are on Linux as dblib is not supported anymore on windows since 
quite a while.

If you are on win usw sqlsrv, works out of the box.

------------------------------------------------------------------------
[2013-03-02 15:57:16] mah at everybody dot org

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

------------------------------------------------------------------------
[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