Edit report at https://bugs.php.net/bug.php?id=64338&edit=1
ID: 64338 User updated by: mah at everybody dot org Reported by: mah at everybody dot org Summary: pdo_dblib can't connect to Azure SQL -Status: Feedback +Status: Open Type: Bug Package: MSSQL related Operating System: any PHP Version: 5.5.0alpha5 Block user comment: N Private report: N New Comment: Yes, this is on Linux. If you're using Azure to host your Linux machine (which I am), it makes sense to use the Azure-hosted SQL database if you can. I've already attached a patch and tested the patch that does exactly what you suggest. Previous Comments: ------------------------------------------------------------------------ [2013-03-02 17:30:56] paj...@php.net 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 :) ------------------------------------------------------------------------ [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