Yii Framework Forum: Can't Connect To Microsoft Sql Server Db - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Can't Connect To Microsoft Sql Server Db

#1 User is offline   tonito0811 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 16-April 13

Posted 16 April 2013 - 10:32 AM

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 :

$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();

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

'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'),
),

___________________________________________________________________
And my db :

'db'=>array(
'class'=>'CDbConnection',
'connectionString'=>'sqlsrv:Server=XX.XX.XXX.XXXX;Database=XXXXXX_XXX',
'username'=>'XXXXXXXXX',
'password'=>'XXXXXXXXX',
'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 :
'CDbConnection failed to open the DB connection: could not find driver'.


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.
0

#2 User is offline   Muaid 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 138
  • Joined: 25-October 10
  • Location:Saudi Arabia

Posted 18 April 2013 - 01:37 PM

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

good luck.
0

#3 User is offline   ItsYii 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 120
  • Joined: 24-January 12

Posted 08 May 2013 - 07:16 AM

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.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users