gpt4 book ai didi

sql-server - 让 Yii 与 SQL Server 完美配合

转载 作者:行者123 更新时间:2023-12-04 18:17:07 26 4
gpt4 key购买 nike

我在我的配置文件中设置了一个数据库连接,如果我打印出 Yii::app() 的内容,我可以找到数据库连接的详细信息,它们是正确的。

然而,当我尝试使用 Gii 模型生成器工具时,它落在了我身上。

53    public function init() {
54 echo '<pre>';
55 print_r(Yii::app()->db);
56 echo '</pre>';
57 die();
58 Yii::app()->db = array(
59 'connectionString' => 'sqlsrv:Server=sti-hq2k8; Database=TrulinXLive',
60 'username' => 'jzumbrum',
61 'password' => 'my_super_secret_password',
62 'charset' => 'utf8',
63 'tablePrefix' => 'tbl',
64 );
65 if(Yii::app()->db===null)
66 throw new CHttpException(500,'An active "db" connection is required to run this generator.');

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

配置设置:
'db'=>array(
'connectionString' => 'sqlsrv:Server=servername; Database=database',
'username' => 'jzumbrum',
'password' => 'password',
'charset' => 'GB2312',
'tablePrefix' => 'tbl',
)

最佳答案

据我记得,我认为一旦禁用模拟准备好的语句,我就不再遇到问题了:

'db'=>array(
'connectionString' => 'sqlsrv:Server=servername; Database=database',
'username' => 'jzumbrum',
'password' => 'password',
'charset' => 'GB2312',
  'tablePrefix' => 'tbl',
'emulatePrepare' =>false
)

此处提供其他可能的问题/修复: http://www.yiiframework.com/forum/index.php/topic/17998-use-sqlsrv-with-php-53x-and-yii/

关于sql-server - 让 Yii 与 SQL Server 完美配合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11462893/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com