Skip to content

Yii连接mssql 数据库配置

2011 七月 6
by 荒野无灯

http://www.microsoft.com/downloads/en/details.aspx?displaylang=en&FamilyID=80e44913-24b4-4113-8807-caae6cf2ca05
下载MSSQL 的PDO 扩展,然后安装释放它到PHP的ext目录下面。
如果你在使用MSSQL2005,那么还需要安装Microsoft SQL Server 2008 R2 Native Client。
请阅读附件的CHM帮助文档里的System Requirements (Microsoft Drivers for PHP for SQL Server) 一节。
然后在 php.ini里面启动该扩展:
例如
PHP 5.3.5 使用 php_pdo_sqlsrv_53_ts_vc6.dllphp_sqlsrv_53_ts_vc6.dll
PHP 5.3.6 则使用 php_pdo_sqlsrv_53_ts_vc9.dllphp_sqlsrv_53_ts_vc9.dll

然后Yii的main config里面像下面这样配置:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
// PDO MSSQL
'db'=>array(
   // 'class'=>'application.components.MyMsSqlConnection',
 
   // old MS PDO + MSSQL 2000:  
   //'connectionString' => 'mssql:host=HOSTNAME\SQLEXPRESS;dbname=Client',
 
   // new MS PDO + MSSQL 2005 2008
   'connectionString' => 'sqlsrv:Server=HOSTNAME\SQLEXPRESS;Database=Client',
      'username' => 'sa',
      'password' => '111',
      'charset' => 'GB2312',
      'tablePrefix' => 'tbl_',
),

译自:http://www.yiiframework.com/wiki/192/config-use-ms-sql-server-2005-2008/

喜欢这篇文章吗?

请订阅本站 RSS feed填写您的邮件地址,订阅我们的精彩内容:,欢迎点击这里捐赠以支持荒野无灯转播到腾讯微博 转播到腾讯微博

作者:荒野无灯
出处:Hacklog【Hacklog】

声明: 本站遵循 署名-非商业性使用-相同方式共享 3.0 共享协议. 转载请注明转自Hacklog【荒野无灯weblog】

本文链接: http://ihacklog.com/?p=4591

Leave a Reply

Allowed Tags - You may use these HTML tags and attributes in your comment.

<a href="" title=""> <abbr title=""> <acronym title=""> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <q cite=""> <strong>

 :wink:  :-|  :-x  :twisted:  :)  8-O  :(  :roll:  :-P  :oops:  :-o  :mrgreen:  :lol:  :idea:  :-D  :evil:  :cry:  8)  :arrow:  :-?  :?:  :!:

Note: You may use basic HTML in your comments. Your email address will not be published.

Subscribe to this comment feed via RSS