【问题标题】:Laravel 5.4 odbc connection MS SQL SERVERLaravel 5.4 odbc 连接 MS SQL SERVER
【发布时间】:2018-04-18 08:19:26
【问题描述】:

我需要配置 Laravel 5.4 以使用 Microsoft SQL Server 的 ODBC PDO 驱动程序。我没有找到任何有用的资源。如果有人以前在 laravel 5.4 中使用过 odbc,请帮助我。

数据库.php

    'odbc'   => [
        'driver'   => 'odbc',
        'dsn'      => 'Driver={SQL Server};Server=
        {serverName};Trusted_Connection=true;Database=meteor;',
        'host'     => 'DESKTOP-B9M4O7M\SQLEXPRESS',
        'database' => 'meteor',
        'username' => 'DESKTOP-B9M4O7M\admin',
        'password' => '',
        'grammar' => [
            'query' => Illuminate\Database\Query\Grammars\SqlServerGrammar::class,
            'schema' => Illuminate\Database\Schema\Grammars\SqlServerGrammar::class,
        ],
     ],

【问题讨论】:

    标签: sql-server-2008 odbc laravel-5.4


    【解决方案1】:

    您错过了一些设置,并误解了其他一些设置。请尝试以下操作:

    'odbc'   => [
        /* USE sql server as the driver, and set odbc settings (see below) */
        'driver'   => 'sqlsrv',
    
        /* Tell laravel that you are using odbc */
        'odbc'     => true,
    
        /* Set the ODBC data source, your previous dns */
        'odbc_datasource_name' => '{SQL Server}',
    
        /* There is no dsn config variable that I am aware of */
        /*'dsn'    => 'Driver={SQL Server};Server={serverName};Trusted_Connection=true;Database=meteor;', */
    
        /* host is the server */
        'host'     => '{serverName}', /*'DESKTOP-B9M4O7M\SQLEXPRESS',*/
    
        'database' => 'meteor',
        'username' => 'DESKTOP-B9M4O7M\admin',
        'password' => '',
        'grammar' => [
            'query' => Illuminate\Database\Query\Grammars\SqlServerGrammar::class,
            'schema' => Illuminate\Database\Schema\Grammars\SqlServerGrammar::class,
        ],
     ],
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-02-04
      • 2013-02-14
      • 2017-07-13
      • 2013-03-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多