zoukankan      html  css  js  c++  java
  • php7.2连接Sqlserver2008 r2

    下载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.3ext

    Wamp切换到PHP7.2.3

    编辑PHP.ini配置文件

    加入扩展

    extension=php_sqlsrv_72_ts.dll
    extension=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',
    <?php
    // 控制器
    namespace appindexcontroller;
    use thinkDb;
    use thinkController;
    
    class Index extends Controller
    {
        public function index()
        {
            $Store = Db::name('sales.store')->field('BusinessEntityID,Name')->paginate(10);
            $this->assign('list',$Store);
            return $this->fetch();
        }
    }
    <!-- 视图 -->
    <!DOCTYPE html>
    <html lang="en">
    
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <link rel="stylesheet" href="static/css/bootstrap.css">
        <title>Document</title>
    </head>
    
    <body style="margin-top: 30px">
        <div class="container">
            <table class="table table-bordered">
                <thead>
                    <tr>
                        <th>BusinessEntityID</th>
                        <th>Name</th>
                    </tr>
                </thead>
                <tbody>
                    {volist name='list' id='Store'}
                    <tr>
                        <td>{$Store.BusinessEntityID}</td>
                        <td>{$Store.Name}</td>
                    </tr>
                    {/volist}
                </tbody>
            </table>
            {$list->render()}
        </div>
    </body>
    
    </html>

  • 相关阅读:
    vue-nuxtjs
    mongodb4.0支持事务
    promisify,promisifyAll,promise.all实现原理
    nodejs, 阿里oss上传下载图片
    数据库备份与还原
    SQL 数据类型、约束、索引及视图
    数据库的查询
    数据库(增、删、改、查)
    数据库基础知识
    C#语言小结
  • 原文地址:https://www.cnblogs.com/liessay/p/8508257.html
Copyright © 2011-2022 走看看