duanpei8518 2019-01-11 16:45
浏览 127

无法通过Laravel 5.7连接到Sybase Central DB

I just installed Laravel 5.7 on my windows 7 machine and I want to use Sybase Central (v6.1) as my database but I can not seem to figure out how to connect to it.

I did a lot of google search but there is not much information out there when it comes to Sybase. This is what I'm trying but it does not work.

'connections' => [
    'sybase' => [
        'driver'   => 'odbc',
        'host'     => env('DB_HOST', 'host-name'),
        'port'     => env('DB_PORT', 'port-number'),
        'database' => env('DB_DATABASE', 'db-name'),
        'username' => env('DB_USERNAME', 'user'),
        'password' => env('DB_PASSWORD', 'password'),
        'charset'  => 'utf8',
        'prefix'   => '',
    ]
]

The error I get

InvalidArgumentException: Unsupported driver [odbc] in \vendor\laravel\framework\src\Illuminate\Database\Connectors\ConnectionFactory.php:283 Stack trace: #0

Does Laravel support Sybase or not?

  • 写回答

1条回答 默认 最新

  • donglu1973 2019-01-11 17:05
    关注

    Out of the box, Laravel doesn't look to support odbc, but there seems to be a package you can install to support it available at ODBC integration for Laravel Framework.

    Simply follow the installation and usage guides on the page, and you should be able to use "driver" => "odbc" without issue.

    From terminal run

    composer require abram/laravel-odbc
    

    Then configure the following files:

    config/database.php

    "connections" => [
        "sybase" => [
            "driver" => "odbc",
            ...
        ]
    ]
    

    config/app.php

    "providers" => [
      ...
      Abram\Odbc\ODBCServiceProvider::class
    ]
    
    评论

报告相同问题?

悬赏问题

  • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效