Can't Connect To Microsoft Sql Server Db


I recently installed Yii to perform a project for my final internship in IT. Everything happened fine until now.

I configured well the index.php in my project file, nothing crazy :



defined(‘YII_DEBUG’) or define(‘YII_DEBUG’,true);

defined(‘YII_TRACE_LEVEL’) or define(‘YII_TRACE_LEVEL’,3);



As you saw, the mail.php file is in the protected/config path. I enabled gii in the module :




// If removed, Gii defaults to localhost only. Edit carefully to taste.



And my db :






'charset' => 'utf8',

'emulatePrepare' => false,


MY db is in Tranact-SQL, so with my research, I found that I need ‘sqlsrv’. This is the first thing I’m not sure (I use SQL management studio).

So I succeded to connect to the Gii screen, but when I get click on the ‘Model generator’, I got this error :

[indent]‘CDbConnection failed to open the DB connection: could not find driver’. [/indent]

I know that a lot of people had the same, but I spent the whole day going thought their topic, and no one made me succeed.I tried quite all the db kind of connection, I think there is some other problem behind this.

One more information, everything is installed on the server and not in local.

If you have an idea ??

Thanks a lot.

make sure you enabled PDO MSSQL driver in PHP configuration file (php.ini)

good luck.

If the message is cannot find driver then it’s likely you don’t have sqlsrv as a PDO extension available. Run phpinfo() where your website is hosted. Search for sqlsrv that should be under PDO heading.