Uncaught PDOException: could not find driver

22 views Asked by At

Currently I'm learnig some PHP, and I come across this error, which I think PHP misundertand that PDO is a method in my namspace app\core. Hope you guys can give me some advice !

<?php
namespace app\core;

class Database
{
    public \PDO $pdo;

    public function  __construct(array $config)
    {
  
        $dsn = $config['dsn'] ?? '';
        $user = $config['user'] ?? '';
        $password = $config['password'] ?? '';
        $this->pdo = new \PDO($dsn, $user, $password);
    }
GET /register - Uncaught PDOException: could not find driver in /root/repo/rep_mvc/core/Database.php:18

I have checked my php_mysql at php.ini, and even uncomment the extension as needed. I also check pdo and it looks ok.

if (!defined('PDO::ATTR_DRIVER_NAME')) {
    echo 'PDO unavailable';
    }
0

There are 0 answers