Upgraded a (dev) Cake PHP site and needed to change database motorists from ADO to SQL Server's own driver as ADO is no more supported in Cake 1.3, I . The brand new SQL Server driver is set up in PHP, shows in PHPinfo() and really should work, however when I attempt to load a webpage while using database, I recieve this error:

Warning (2): sqlsrv_query() expects parameter 1 to be resource, boolean given 
[APP\plugins\datasources\models\datasources\dbo\dbo_sqlsrv.php, line 184]
Warning (512): SQL Error: An invalid parameter was passed to sqlsrv_query.
 [CORE\cake\libs\model\datasources\dbo_source.php, line 684]

What seems to become happening is my connection is not established within the dbo_sqlsrv.php driver a "$this->connection" variable should be the bond resource then passed to sqlsrv_query() and it is apparently a bool that is wrong (I attempted to Echo the variable also it shows nothing).

This is when the bond Ought to be set:

sqlsrv_connect($this->config['host'] . $port, $params)

Printing the variables which were passed in provides me with this:

SRV, 1433 Array ( [Database] => DB [CharacterSet] => char 
[MultipleActiveResultSets] => [UID] => sa [PWD] => password )

All of individuals parameters is correct, it is possible to specific way I ought to format or change my database configuration array with this driver or perhaps is there something I'm missing?

This error was because of outdated SQL Server motorists. Setting up the most recent from below enables a SQL Server connection:


I believe there's some problem together with your connection. PHP can't establish reference to sql Server.

var $default = array(
        'driver' => 'sqlsrv',
        'persistent' => false,
        'host' => 'Myhome-PC\SQLEXPRESS', // or ip-address(
        'login' => 'username',
        'password' => 'password',
        'database' => 'db',
        'prefix' => 'tbl',
        'port' => NULL,
        'returnDatesAsStrings' => True

I believe the bond ought to be this

This is actually the sqlsrv_dbo that we used.

As well as your $param ought to be something similar to this

$connectionInfo = array("UID" => $config['login'], 
                        "PWD" => $config['password'], 
                        "Database" => $config['database'],   
                        'MultipleActiveResultSets' => 1,
                        'ConnectionPooling' => 0
         $connectionInfo['ReturnDatesAsStrings'] = $config['ReturnDatesAsStrings'];
$this->connection = sqlsrv_connect($config['host'] . $port, $connectionInfo);