下载Sql Server PHP扩展
Microsoft Drivers for PHP for SQL Server
https://github.com/Microsoft/msphpsql/releases/tag/v5.2.0-RC
https://github.com/Microsoft/msphpsql/tags(全部连接)
下载ODBC驱动
Microsoft® ODBC Driver 13.1 for SQL Server
https://www.microsoft.com/en-us/download/details.aspx?id=53339
下载的文件放入php7.2.3\ext
Wamp切换到PHP7.2.3
编辑PHP.ini配置文件
加入扩展
extension=php_sqlsrv_72_ts.dllextension=php_pdo_sqlsrv_72_ts.dll
退出Wamp重新打开用phpinfo()查看
ThinkPHP 5 测试
database.php
// 数据库类型'type' => 'sqlsrv',// 服务器地址'hostname' => '127.0.0.1',// 数据库名'database' => 'AdventureWorks2008R2',// 用户名'username' => 'sa',// 密码'password' => 'Sa123',
field('BusinessEntityID,Name')->paginate(10); $this->assign('list',$Store); return $this->fetch(); }}
Document {$list->render()}
{volist name='list' id='Store'} BusinessEntityID Name {/volist} {$Store.BusinessEntityID} {$Store.Name}