// Method 1:
PDO::__construct($dsn, $user, $pass, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8';"));
// Method 2:
PDO::__construct($dsn, $user, $pass);
PDO::exec("SET NAMES 'utf8';");
Both methods can be used To solve the problem, the principle is the same, whichever one you use depends on your preference