Yii Framework Forum: WAMP + Yii + MSSQL == Driver not found - Yii Framework Forum

Jump to content

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

WAMP + Yii + MSSQL == Driver not found Rate Topic: -----

#1 User is offline   UltraPhil 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 05-July 11

Posted 14 August 2012 - 10:01 AM

Hi there,

I've got a WAMP setup (work machine..) version 2.2 with PHP 5.3.13 with MSSQL and PDO_MSSQL loaded. I've looked at quite all the topics on this forum but could not resolve my problem:

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


I've tried different connectionStrings, none work, I ended up with:

'db' => array(
	    'connectionString' => 'mssql:host=127.0.0.1;dbname=Yiitest',
	    'username' => 'UltraPhil',
	    'password' => '...',
	    'charset' => 'utf8',
	    'emulatePrepare' => false,
	),


2012/08/13 19:53:51 [error] [exception.CDbException] exception 'CDbException' with message 'CDbConnection failed to open the DB connection: could not find driver' in C:\wamp\www\yii-1.1.11.58da45\framework\db\CDbConnection.php:382
Stack trace:
#0 C:\wamp\www\yii-1.1.11.58da45\framework\db\CDbConnection.php(331): CDbConnection->open()
#1 C:\wamp\www\yii-1.1.11.58da45\framework\db\CDbConnection.php(309): CDbConnection->setActive(true)
#2 C:\wamp\www\yii-1.1.11.58da45\framework\base\CModule.php(388): CDbConnection->init()
#3 C:\wamp\www\yii-1.1.11.58da45\framework\base\CModule.php(104): CModule->getComponent('db')
#4 C:\wamp\www\yii-1.1.11.58da45\framework\gii\generators\model\ModelCode.php(56): CModule->__get('db')
#5 C:\wamp\www\yii-1.1.11.58da45\framework\web\CFormModel.php(40): ModelCode->init()
#6 C:\wamp\www\yii-1.1.11.58da45\framework\gii\CCodeGenerator.php(154): CFormModel->__construct()
#7 C:\wamp\www\yii-1.1.11.58da45\framework\gii\CCodeGenerator.php(64): CCodeGenerator->prepare()
#8 C:\wamp\www\yii-1.1.11.58da45\framework\web\actions\CInlineAction.php(50): CCodeGenerator->actionIndex()
#9 C:\wamp\www\yii-1.1.11.58da45\framework\web\CController.php(309): CInlineAction->runWithParams(Array)
#10 C:\wamp\www\yii-1.1.11.58da45\framework\web\CController.php(287): CController->runAction(Object(CInlineAction))
#11 C:\wamp\www\yii-1.1.11.58da45\framework\web\CController.php(266): CController->runActionWithFilters(Object(CInlineAction), Array)
#12 C:\wamp\www\yii-1.1.11.58da45\framework\web\CWebApplication.php(283): CController->run('')
#13 C:\wamp\www\yii-1.1.11.58da45\framework\web\CWebApplication.php(142): CWebApplication->runController('gii/model')
#14 C:\wamp\www\yii-1.1.11.58da45\framework\base\CApplication.php(162): CWebApplication->processRequest()
#15 C:\wamp\www\yiitest\index.php(13): CApplication->run()
#16 {main}
REQUEST_URI=/yiitest/index.php/gii/model
HTTP_REFERER=localhost/yiitest/index.php/gii


As I said, I already read a lot of other threads, and I still can't resolve this one.

Thanks!
0

#2 User is offline   rootbear 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 222
  • Joined: 17-June 11

Posted 14 August 2012 - 10:56 AM

i struggled a bit migrating mysql to mssql and finally made it work.

here is my setting, in php.ini (i could not make ;extension=php_mssql.dll work)

extension=php_sqlsrv_53_ts_vc9.dll
extension=php_pdo_sqlsrv_53_ts_vc9.dll


in protected/config/main.php

'db' => array(
            'connectionString' => 'sqlsrv:server=127.0.0.1;dbname=Yiitest',
            'username' => 'UltraPhil',
            'password' => '...',
        ),


there're also some tune-ups need to be done, like

in mysql we use

limit 100


in mssql, we use

top 100


don't ask me too much, that's all i know. initially i thought yii would support any db in a neutral way, but actually not all DBs were created equal.
I enjoy the Yii.sy coding life here.
0

#3 User is offline   UltraPhil 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 05-July 11

Posted 14 August 2012 - 11:51 AM

Alright!

Figured out.

- Needed to install Wamp Server x86 ( had x64 ).
- Downloaded SQLSRV30 from microsoft and added to php.ini:
extension=php_sqlsrv_53_ts.dll
extension=php_pdo_sqlsrv_53_ts.dll

- Needed to comment out 'emulatedPrepare', true OR false would give me an error:
SQLSTATE[IMSSP]: The given attribute is only supported on the PDOStatement object.


Now it works.
Thanks !
(and I hope it helps someone someday).
0

#4 User is offline   delmi 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 10
  • Joined: 30-October 10
  • Location:Firenze (Italy)

Posted 05 March 2013 - 10:11 AM

View PostUltraPhil, on 14 August 2012 - 11:51 AM, said:


- Needed to comment out 'emulatedPrepare', true OR false would give me an error:
SQLSTATE[IMSSP]: The given attribute is only supported on the PDOStatement object.




Wow... thanks!!!!
Just commented out emulatePrepare and it is working.
I'm on IIS 7.5, PHP 5.4.12 NTS and php_pdo_sqlsrv_54_nts.dll extension on Windows 2008 R2 + MS Sql Server 2005.

Wondering why both true/false values gives error?!
But the important thing is that now it works!

Thanks again,
Angelo
0

#5 User is offline   tomsea 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 66
  • Joined: 25-November 11

Posted 06 March 2013 - 03:43 PM

View Postdelmi, on 05 March 2013 - 10:11 AM, said:

Wondering why both true/false values gives error?!
But the important thing is that now it works!

Thanks again,
Angelo


Maybe it's because the default value of emulatePrepare is neither true nor false, it's null:

http://www.yiiframew...ePrepare-detail

The documentations says at the beginning that the default value is false, but later it says it's null (maybe a mistake in the documentation).

It seems that a null value is treated differently for this attribute.
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