I'm collecting data stored in database, and I've seen that there are some columns that have strange characters.
Example (Extracted from php)
The sport is not being valued enough and the situation is very fucked
Example (Stored in mysql)
The sport is not being valued enough and the situation is very fucked
Code Excerpt
The object of type DatabaseConnection
contains an instance of an object of type mysqli.
class DatabaseConnection {
/**
* @var mysqli
**/
protected $_db;
/**
* Database connection construct
* @param string $host
* @param string $user
* @param string $password
* @param string $bd
* @construct
**/
public function __construct( $host = 'localhost', $user = 'root', $password = '***', $bd = 'testing' ){
$this->_db = new mysqli( $host, $user, $password, $bd );
if ( mysqli_connect_errno() ){
return false;
}
return true;
}
/**
* Do mysql query
* @param string $str
**/
public function query ( $str ){
$res = $this->_db->query ( $str );
return $res;
}
/**
* Close mysql connection
**/
public function close(){
$this->_db->close();
}
}
$connection = new DatabaseConnection( $config['database']['host'], $config['database']['user'], $config['database']['pass'], $config['database']['db'] );
$query = "select * from news where tipo = 'news' limit 10";
$res = $connection->query( $query );
$arr = [];
if ( $res ){
while ( $row = $res->fetch_assoc() ){
$arr[] = $row;
}
return $arr;
}
I would like to know if there is any way of replacing these characters with their real value, in this case they would be vowels with accents.
Thank you,
Ismael.