PHP PDlib PDO Problem

I am trying to connect to the MSSQL server through php, but my pdo connection gives me hard time and errors that I really don't understand. The code I pasted below worked perfectly, a week ago, and suddenly it just stopped, without changing anything. I can still connect to the server and run requests directly from the command line, but I don't have the same luck in php. Does anyone see what I am missing? I have spent too much time on this already, and it seems that I am running in circles.

Firstly, this is the error I get from my PDOException

SQLSTATE[] (null) (severity 0)

Part of my Mssql ()

 private function __construct() {
        try{
           $this->_pdo = new PDO('dblib:host=' . Config::get('prod/host') . ':'. Config::get('prod/port') .';dbname=' . Config::get('prod/db'),Config::get('prod/username'), Config::get('prod/password'));
        }catch(PDOException $e){
            die($e->getMessage());
        }
    }

    public static function getInstance(){
        // Already an instance of this? Return, if not, create.
        if (!isset(self::$instance)) {
            self::$instance = new Mssql();
        }
        return self::$instance;
    } //...This function is working and directs to __construct()

As i call it

/*Some random php file*/
function getClients(){
    $conn = Mssql::getInstance();
//.....

And my init.php

//...
prod' => array(
        'host'      => 'xxxxxxx',
        'port'      => '1433',
        'username'  => 'xxxxxxx',
        'password'  => 'xxxxxx',
        'db'        => 'xxxxxxx'
    ),
//.....
+4
source share
1 answer

dblib odbc, :

 private function __construct() {
        putenv('ODBCSYSINI=/etc');
        putenv('ODBCINI=/etc/odbc.ini');
        $username = "xxxx";
        $password = "xxxx";
        try {
            $this->_pdo = new PDO("odbc:production","$username","$password");
        } catch (PDOException $exception) {                
            die($exception->getMessage());
        }
+1

Source: https://habr.com/ru/post/1627941/


All Articles