CDbConnection 无法打开数据库连接:SQLSTATE[IMSSP]: The given attribute is only supported on the PDOStatement object

sk0*_*001 0 php yii sql-server-2008

我是 Yii 框架编程的初学者。想要使用 Gii 扩展,我无法使用。某些功能,例如 Crud 生成器,会生成异常。

CDbConnection failed to open the DB connection: SQLSTATE[IMSSP]: The given attribute is only supported on the PDOStatement object. 
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

在我的main.php配置文件中,我有以下与连接字符串、导入和模块变量相关的代码部分:

'import'=>array(
    'application.models.*',
    'application.components.*',
            'ext.giix-components.*',
        //additionally added for Giix
),

'modules'=>array(
    // uncomment the following to enable the Gii tool

    'gii'=>array(
        'class'=>'system.gii.GiiModule',
        'password'=>'pass',
                    'generatorPaths' => array('ext.giit-core'),
        // If removed, Gii defaults to localhost only. Edit carefully to taste.
        'ipFilters'=>array('127.0.0.1','192.168.0.83'),

    ),

),

// application components
'components'=>array(
    'user'=>array(
        // enable cookie-based authentication
        'allowAutoLogin'=>true,
    ),

    'db'=>array(
        'connectionString' => 'sqlsrv:Server=192.168.0.2;Database=DBStage',
        'emulatePrepare' => FALSE,
        'username' => 'user',
        'password' => 'pass',
        'charset' => 'utf8',
                    'tablePrefix' => 'tbl',
    ),
Run Code Online (Sandbox Code Playgroud)

有人可以帮忙吗?

sk0*_*001 5

我需要精确CDbConnection类并删除变量数组中的emulatePreparetablePrefix条目db。不是它看起来像这样,也能正常工作。但是,我为此失去了一天。

'db'=>array(
    'class' => 'CDbConnection',
    'connectionString' => 'sqlsrv:Server=192.168.0.2;Database=DBStage',
    //'emulatePrepare' => FALSE,
    'username' => 'user',
    'password' => 'pass',
    'charset' => 'utf8',
                //'tablePrefix' => 'tbl',
),
Run Code Online (Sandbox Code Playgroud)

希望它会帮助某人。