What are the differences in setting character encoding between MySQL and PgSQL when using PDO in PHP?

When using PDO in PHP to connect to MySQL, the character encoding can be set using the `charset` option in the DSN string, such as `charset=utf8`. On the other hand, when connecting to PgSQL, the character encoding can be set using the `options` parameter in the PDO constructor, specifying the `PGSQL_ATTR_INIT_COMMAND` option with the appropriate SQL command to set the encoding, such as `SET NAMES 'utf8'`.

// For MySQL
$dsn = "mysql:host=localhost;dbname=mydatabase;charset=utf8";
$username = "username";
$password = "password";
$options = array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8');
$pdo = new PDO($dsn, $username, $password, $options);

// For PgSQL
$dsn = "pgsql:host=localhost;dbname=mydatabase";
$username = "username";
$password = "password";
$pdo = new PDO($dsn, $username, $password);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$pdo->setAttribute(PDO::PGSQL_ATTR_INIT_COMMAND, 'SET NAMES utf8');