I'm using PDO ODBC Driver 13 with Linux Apache, everything works correctly except for the following: If I sample the rows in a table using fetch and if the word has special characters, it removes the last character from the word. For example: The word 'Maça' gives me the result 'Maç', but if I write 'maçaa' the result is as expected, 'maça'
My settings are as follows:
Class DatabaseODBC{
private $server = "odbc:Driver={ODBC Driver 13 for SQL Server};Server=--, 1433;Database=--;Server_CSet=UTF-8;Client_CSet=UTF-8;";
private $username = "--";
private $password = "--";
private $options = array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,);
protected $conn;
public function open(){
try{
$this->conn = new PDO($this->server, $this->username, $this->password, $this->options);
return $this->conn;
}
catch (PDOException $e){
echo "Problem with connection " . $e->getMessage();
}
}
public function close(){
$this->conn = null;
}
}
The index page is:
$stmt = $connODBC->prepare("SELECT 'MAÇA' as text, name FROM users(nolock) WHERE id = :id");
$stmt->execute(['id' => 1]);
foreach ($stmt as $row) {
echo $row["text"];
}