I'm querying ibm as400 system (sql). When a value has special chars it returns like "IDSUNM" => b"Çamsan"
. Can't understand whats the b"
before the actual value. When the value doesn't have special chars, it returns OK, "IDSUNM" => "A definir"
.
Functions that connects to sql:
protected function connection_as400($query = null)
{
// Try to open a connection
try {
$params = "odbc:DRIVER={".config('database.connections.as400.driver')."}; SYSTEM={".config('database.connections.as400.host')."}; DATABASE={".config('database.connections.as400.database')."}; UID={".config('database.connections.as400.user')."}; PWD={".config('database.connections.as400.password')."};charset=utf8;";
//dd($params);
$as400_connection = new PDO($params);
return $as400_connection;
// If we can't establish a connection, show error...
} catch (PDOException $e) {
$as400_connection = null;
dd($e->getMessage());
}
return 0;
}
How I'm quering the system:
$as400_connection = $this->connection_as400();
$query = $as400_connection->query("SELECT IDSUNO, IDSUNM FROM MVXBDTA.CIDMAS WHERE IDCONO = 1");
$results = $query->fetchAll(PDO::FETCH_ASSOC);
Results:
1 => array:2 [▶
"IDSUNO" => "1804"
"IDSUNM" => b"Çamsan"
]
5 => array:2 [▶
"IDSUNO" => "*"
"IDSUNM" => "A definir"
]
Thanks for any help given.