Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unknown PDO attribute ATTR_CONNECTION_STATUS #1049

Closed
ehv1 opened this issue Jun 24, 2022 · 1 comment
Closed

Unknown PDO attribute ATTR_CONNECTION_STATUS #1049

ehv1 opened this issue Jun 24, 2022 · 1 comment
Labels

Comments

@ehv1
Copy link

ehv1 commented Jun 24, 2022

Information

  • Version of Medoo: 2.1
  • Version of PHP: 8.1
  • Type of Database (MySQL, MSSQL, SQLite...): MSSQL 2019
  • System (Liunx|Windows|Mac): Linux

When using: print_r($database->info());
I get the following error:

PHP Fatal error:  Uncaught PDOException: SQLSTATE[IMSSP]: An invalid attribute was designated on the PDO object. in /work/sqlserv/vendor/catfan/medoo/src/Medoo.php:2226
Stack trace:
#0 /work/sqlserv/vendor/catfan/medoo/src/Medoo.php(2226): PDO->getAttribute()
#1 /work/sqlserv/test.php(42): Medoo\Medoo->info()
#2 {main}
  thrown in /work/sqlserv/vendor/catfan/medoo/src/Medoo.php on line 2226

According to the information printed on this page:
https://docs.microsoft.com/en-us/sql/connect/php/pdo-getattribute?view=sql-server-ver15
there is no PDO::ATTR_CONNECTION_STATUS.

When I comment out ATTR_CONNECTION_STATUS then it's working:

     /**
      * Get information about the database connection.
      *
      * @codeCoverageIgnore
      * @return array
      */
     public function info(): array
     {
         $output = [
             'server' => 'SERVER_INFO',
             'driver' => 'DRIVER_NAME',
             'client' => 'CLIENT_VERSION',
             'version' => 'SERVER_VERSION',
             //'connection' => 'CONNECTION_STATUS'
         ];

         foreach ($output as $key => $value) {
             $output[$key] = @$this->pdo->getAttribute(constant('PDO::ATTR_' . $value)); // Line 2226 ...
         }

         $output['dsn'] = $this->dsn;

         return $output;
     }
print_r($database->info());

Array
(
    [server] => Array
        (
            [CurrentDatabase] => Datawarehouse
            [SQLServerVersion] => 15.00.2080
            [SQLServerName] => DATAWAREHOUSE
        )

    [driver] => sqlsrv
    [client] => Array
        (
            [DriverName] => libmsodbcsql-18.0.so.1.1
            [DriverODBCVer] => 03.52
            [DriverVer] => 18.00.0001
            [ExtensionVer] => 5.10.1+15713
        )

    [version] => 15.00.2080
    [dsn] => sqlsrv:Server=172.16.24.1;Database=Datawarehouse;Encrypt=0
)
@catfan
Copy link
Owner

catfan commented Jun 25, 2022

It seems the @ error control operator has been deprecated on PHP 8.0.

I will fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants