1 'Sqlsrv', 4 'DB_HOST' => '127.0.0.1', 5 'DB_PORT' => '1433', 6 'DB_NAME' => 'demo', 7 'DB_USER' => 'sa', 8 'DB_PWD' => '', 9 'DB_PREFIX' => 'demo_'10 );11 ?>
1. 以上代码在项目配置目录Conf的 confgi.php配置文件中定义。
2. php扩展里要先安装MS SQL Server drivers for PHP (非PDO驱动)
3. 服务器上要安装MS SQL Server Native Client 2012
用PDO驱动MS SQL Server 2008 R2方法如下:
'pdo', 'DB_HOST' => '127.0.0.1', 'DB_PORT' => '1433', 'DB_NAME' => 'demo', 'DB_USER' => 'sa', 'DB_PWD' => '', 'DB_PREFIX' => 'demo_', 'DB_DSN' => 'sqlsrv:Server=127.0.0.1; Database=demo' );?>
PDO 方式可简化为以下代码:
'pdo', 'DB_HOST' => '127.0.0.1', 'DB_USER' => 'sa', 'DB_PWD' => '', 'DB_PREFIX' => 'demo_', 'DB_DSN' => 'sqlsrv:Server=127.0.0.1; Database=demo' );?>