Can't Connect To Microsoft Sql Server Db

Hello,

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 :

[indent]$yii=dirname(FILE).’/../framework/yii.php’;

$config=dirname(FILE).’/../protected/config/main.php’;

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

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

require_once($yii);

Yii::createWebApplication($config)->run();[/indent]


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

[indent]‘gii’=>array(

'class'=>'system.gii.GiiModule',


'password'=>'XXXXXXXXX',


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


'ipFilters'=>array('XX.XX.XXX.XX'),

),[/indent]


And my db :

[indent]‘db’=>array(

'class'=>'CDbConnection',		


'connectionString'=>'sqlsrv:Server=XX.XX.XXX.XXXX;Database=XXXXXX_XXX',


'username'=>'XXXXXXXXX',


'password'=>'XXXXXXXXX',


'charset' => 'utf8',


'emulatePrepare' => false,

),[/indent]


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.