繁体   English   中英

CDbConnection无法打开数据库连接:SQLSTATE [IMSSP]:仅在PDOStatement对象上支持给定属性

[英]CDbConnection failed to open the DB connection: SQLSTATE[IMSSP]: The given attribute is only supported on the PDOStatement object

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

CDbConnection failed to open the DB connection: SQLSTATE[IMSSP]: The given attribute is only supported on the PDOStatement object. 

在此处输入图片说明

在我的main.php配置文件中,我具有与连接字符串,import和modules变量相关的以下代码部分:

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

有人可以帮忙吗?

我需要精确调整CDbConnection类,并删除我的db变量数组中的emulatePreparetablePrefix条目。 看起来不是这样,并且效果很好。 但是,我为此失去了一天。

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

希望它会帮助别人。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM