Questa è una parte della mia classe DOP. Devo usare utf-8
per la lingua ebraica ma quando ho impostato ATTR_PERSISTENT
su true
il testo di output verrà visualizzato come ??????
Se si passa da ATTR_PERSISTENT
a false
, l'output sarà corretto.PHP PDO, Impossibile impostare il nome mentre la connessione è persistente?
public function __construct() {
// Set DSN
$dsn = 'mysql:host=' . $this->host . ';dbname=' . $this->dbname;
// Set options
$options = array(
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_PERSISTENT => true
);
// Create a new PDO instanace
try {
$this->dbh = new PDO($dsn, $this->user, $this->pass, $options);
}
// Catch any errors
catch (PDOException $e) {
$this->error = $e->getMessage();
}
}
Esiste un conflitto tra:
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'
E:
PDO::ATTR_PERSISTENT => true
Quali sono i tipi di file di codifica? – rray
@rray È utf-8 –
Ciò che è curioso, è che è stato [chiesto prima] (http://stackoverflow.com/questions/29714253/pdoattr-persistent-utf-8-encoding) e non ha catturato quasi nessuna attenzione. –