When you upgrade php, make sure you also install all the required php extensions for the upgraded version. The Ubuntu specific instructions might be useful:
https://docs.nextcloud.com/server/stable/admin_manual/installation/example_ubuntu.html
The full module list is here just in case:
I suspect that error is because you’re missing the one for your database, but you’re likely also missing the rest if you upgraded.