phpsql-serverlaravel

Laravel 10 stopped working with SQL Server Database


all of a sudden my laravel app has stopped connecting to SQL server database. No matter what i do, i get the error

SQLSTATE[IMSSP]: An invalid attribute was designated on the PDO object.

I am able to connect to the database as usual from Microsoft Management Studio and as far as i am concerned nothing has change to the server configuration.

The OS of the server is AlmaLinux 8.8 and it has been running well for the last couple of months that the project started.

Route::get('/check_db', function() {
    try {
        DB::connection('sqlsrv')->getPDO();
        echo DB::connection()->getDatabaseName();
    } catch (\Exception $e) {
        echo 'None';
    }
});

Adding the above line on the web.php and visiting the link i get None

phpinfo() output enter image description here

enter image description here

PHP version 8.2.9

PS. It works great with MySQL databases. PS2. Before you downgrade for duplicate, i need to mention that i already searched everything on stackoverflow and laracasts for this specific error and nothing helped me resovle it.

Any info on what is going wrong?


Solution

  • EDIT (2023-09-30)

    The updated version 5.11.1 of (pdo_)sqlsrv has been released in the beginning of September (github tag). It contains the pull request mentioned below.

    Previous answer

    The reason is PHP 8.1.22 and 8.2.9 contain a fix for MySQL which uncovered a bug in sqlsrv extension: one of PDO attributes isn't supported in the extension and return an error if set. More information can be found in this Drupal thread.

    The error should be fixed by this merged pull request in next release.

    In the meantime you can either:

    or