Use sqlsrv with php 5.3.x and Yii

Hello everybody,

My config :

  • OS : Windows XP

  • Php/Apache Srv : WAMP (php 5.3.0)

I try to connect my little project to a MsSql db. And then create my models.

  1. I modified my config/main.php :


	'connectionString' => 'sqlsrv:host=myServer;port:1433;dbname=myDB',

	'emulatePrepare' => false,

	'username' => 'sa',

	'password' => '123456',


  1. I have this error message :


CDbConnection failed to open the DB connection: [08001][Microsoft][SQL Server Native Client 10.0]SQL Server Network Interfaces: Connection string is not valid [87].

I’m sure that the server is accessible, this code is working :

$connectionInfo = array(





$dbhandle = sqlsrv_connect($myServer, $connectionInfo) 

	or die("Couldn't connect to SQL Server on $myServer : <br />".print_r(sqlsrv_errors(), true));

$query = sqlsrv_query($dbhandle, 'SELECT * FROM myTable');

while($obj = sqlsrv_fetch_object($query))

	echo $obj->name.'<br />';

I use the sqlsrv because the mssql is not longer supported by php 5.3.0. Is it possible to use sqlsrv with Yii ?

If yes, how ?

Thanks for your help.

I don’t use this database… but as the error says “connection string is not valid”… I just googled “sqlsrv connection string” and got these two pages

So try to change your connection string… as on these examples there is no "host=" for the connection string


Tanks for your help.

Indeed, the connectionString contained mistakes. I changed to


  'connectionString' => 'sqlsrv:Server=myServer;Database=myDB',

  'username' => 'sa',

  'password' => '123456',

  'emulatePrepare' => false,

  'charset' => 'utf8',


Now, I have this message :

I’m sure that the server is accessible (see my fist post) with the command sqlsrv_connect().

What I’m doing wrong ? I must maybe change my PHP extensions… I’m using :



Yii is a very powerful framework and I want to use it for a European project. Unfortunately, the connection to a mssql server is needed.


Again… try to google for this kind of errors as they are not Yii related…

I just googled "Named Pipes Provider error 53" and here is a good explanation


It works ! :)

The problem came just from the version of the PHP extension php_pdo_sqlsrv_53_ts_vc6.dll. Now, I use the version 2.0.1802.200.

I downloaded the dlls here :

Many thanks for your help and sorry for my "non-related to Yii" question.


this file:

php_sqlsrv_54_ts.dll, php_pdo_sqlsrv_54_ts.dll

It will running on linux?

I am using

centos 6.5

ms sql 2000

php 5.6.0RC4

and installed [size=&quot;2&quot;]php-mssql.[/size]

[size="2"]But I still cannot connect to mssql. My config as below[/size]



    			'connectionString' => 'mssql:host=;dbname=eBooking',

                        'username' => 'sa',

    			'password' => '123456',

                        'emulatePrepare' =>false



[size="2"]I want to create model using gii and error display as below. Please help[/size]


CDbConnection failed to open the DB connection: could not find driver


public function init()



        throw new CHttpException(500,'A valid database connection is required to run this generator.');






Im having a big problem trying to connect YYI whtich MS SQL EXPRESS 2005

im using XAMP server,on a VM with WServer 2003 R2 32 bit

with PHP 5.4.31

y donwload and install



also de MS SQL Native client 2005

and y try connecting with this script


$serverName = "\sqlexpress"; //serverName\instanceName

$connectionInfo = array( "Database"=>"test4", "UID"=>"test", "PWD"=>"test");

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

if( $conn ) {

 echo &quot;Conexión establecida.&lt;br /&gt;&quot;;


 echo &quot;Conexión no se pudo establecer.&lt;br /&gt;&quot;;

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



It work fine

but when i try YII

it didnt connect,

my web page freeze and never stop

i’m using this connection script


  'connectionString' =&gt; ';Database=test4',

      'username' =&gt; 'test',

      'password' =&gt; 'test',

      'emulatePrepare' =&gt; false,

      'charset' =&gt; 'utf8',



what is wrong???

Can you download latest version of the SQL driver? Such as below or even more latest? thx.



Hi, anyone can help me? I have this problem:

CDbCommand falló al ejecutar la sentencia SQL: SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘pbis_meta.pbi_security_user’ doesn’t exist. The SQL statement executed was: SELECT * FROM pbis_meta.PBI_SECURITY_USER

what’s happend?

How can I know if the connectionString is wrong or not?