先下载sqlsrv 驱动 下载地址
sqlsrv 驱动
3.0 对应 php 5.4 3.1 对应 php 5.5复制下载的文件到php的ext目录下 php_pdo_sqlsrv_55_nts.dll php_pdo_sqlsrv_55_ts.dll php_sqlsrv_55_nts.dll php_sqlsrv_55_ts.dll
打开php.ini文件 添加 extension=php_pdo_sqlsrv_55_nts.dll extension=php_pdo_sqlsrv_55_ts.dll extension=php_sqlsrv_55_nts.dll extension=php_sqlsrv_55_ts.dll
数据库配置格式为
'db_type' => 'pdo', 'db_user' => 'XX', 'db_pwd' => 'XXXXXXXX', 'DB_DSN' => 'sqlsrv:Server=XXXXXX;Database=XXXX',代码格式 $User = M('表名','dbo.','sqlsrv://数据库账号:数据库密码@数据库地址/数据库名称'); $userinfo = $User ->select();