How can the use of object-oriented programming in PDO impact PHP projects in the long term?

Using object-oriented programming in PDO can improve the structure and organization of PHP projects in the long term by promoting code reusability, modularity, and maintainability. By encapsulating database operations within classes and objects, developers can easily manage database connections, queries, and transactions, leading to more efficient and scalable code.

class Database {
    private $host = 'localhost';
    private $db_name = 'dbname';
    private $username = 'username';
    private $password = 'password';
    private $conn;

    public function connect() {
        $this->conn = new PDO("mysql:host=$this->host;dbname=$this->db_name", $this->username, $this->password);
        $this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        return $this->conn;
    }

    public function disconnect() {
        $this->conn = null;
    }
}