Viewed   134 times

I'm trying to connect from php to Azure DB by

$connectionInfo = array("UID" => "xxx@xxx", "pwd" => "xxx", "Database" => "xxx");
$serverName = ",1433";
$conn = sqlsrv_connect($serverName, $connectionInfo);

But it gives me

Fatal error: Call to undefined function sqlsrv_connect() in C:wampwww...index.php on line 19



you have to use the SQL Server native driver for php at first place, then you can do something like:

$serverName = ", 1433";

$connectionOptions = array("Database" => "sampleInit", 

                           "UID" => "sampleUsr@sample",

                           "PWD" => "samplePass",

                           "MultipleActiveResultSets" => false);

$conn = sqlsrv_connect($serverName, $connectionOptions);

if($conn === false)


     die(print_r(sqlsrv_errors(), true));


You can read more on PHP and SQL Azure at following blog post:

Tuesday, October 4, 2022

In CI framework, if you are running a prod application, we can set pconnect to true in config/database.php to use a persistent connection to database. Which can reduce latency on initial connection.

By the way, if you are running a test or dev application, we need to treat carefully with this setting, because it may cause several unexpected issues. You can refer to the answer of Advantages / Disadvantages of pconnect option in CodeIgniter to get more info.

Friday, September 30, 2022

The error is caused by the use of the wrong version of TDS.

To resolve just specify the TDS version before the tsql command:

TDSVER=8.0 tsql -H -U Username -D DatabaseName -p 1433 -P Password
Monday, October 10, 2022

You can calculate used space via dynamic management views (reference page here):

SELECT SUM(reserved_page_count)*8.0/1024
FROM sys.dm_db_partition_stats; 

While I don't think you can retrieve max size, it doesn't hurt to simply set your database to the largest size, since you're only billed for space you use. Having said that: If you're only in the sub-5GB range, it's best to go with Web edition. If you're already at 10+ GB, there shouldn't be any harm setting max size to 150GB and then monitoring consumed size.

Sunday, October 16, 2022

The solution was to update to the newest SDK.

Tuesday, November 15, 2022
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :