You desperately need to upgrade.
Setting the encoding in DSN is supported with PHP 5.3.6. And this version, for a minute, is already 5 years old, and it has not been supported for a long time.
Setting the encoding with the SET NAMES query is a crutch, since this method does not change the internal encoding of the client, and the formatting of strings is done without regard to encoding. This situation should be avoided because in rare cases it can lead to injections.
Setting the encoding in DSN is the only correct option.
And working on an unsupported version of PHP faces many problems, from security to incompatibility.