laravel / framework

The Laravel Framework.
https://laravel.com
MIT License
32.16k stars 10.88k forks source link

Illuminate\Database\Connection#getPDO returns null #14914

Closed luqmanrom closed 8 years ago

luqmanrom commented 8 years ago

I am using uepg/laravel-sybase package to connect to a remote Sybase database. I had an issue where sometimes the request I made from API call returned a correct result by querying the remote Sybase server but sometimes it is giving me this error.

{
  "message": "Call to a member function query() on null",
  "code": 1,
  "status_code": 500,
  "debug": {
    "line": 218,
    "file": "/var/www/html/iharga/vendor/uepg/laravel-sybase/Database/SybaseConnection.php",
    "class": "Symfony\\Component\\Debug\\Exception\\FatalErrorException",
    "trace": [
      "#0 {main}"
    ]
  }
}

After I check the SybaseConnection.php file, it turned out that it is actually a class extending Illuminate\Database\Connection and the error happened when I think getPDO() from the Connection class is called and it returns null.

return $this->getPdo()->query($this->compileNewQuery($query, $bindings));

It is working perfectly fine on my local, on staging using Ubuntu but not on production using RedHat. Any idea why?

srmklive commented 8 years ago

Only thing i can think of is that the php_sybase extension is not enabled on your production server

luqmanrom commented 8 years ago

It is enabled I believe. But I fixed it by upgrading the FreeTDS to version 1.0 instead of the old one version 0.91 which is in the repositories of the RedHat