I am using [REDBEANPHP 3.5 | easy ORM for PHP] and working with me for all parts in my app but now I have a problem while select data from database with Arabic content via
R::setup('mysql:host=' . DB_HOST . ';dbname=' . DB_NAME, DB_USER, DB_PASSWORD);
$sql = "select * from comments";
$comments = R::getAll($sql);
echo "<pre>";
die(print_r($comments));
I am getting data as
["comment_content"]=> "تجربة ممتازة وتستØÙ‚ التكرار"
I am searching for that and know default encoding in REDBEANPHP is UTF8 also found setEncoding function called inside RedBean_Driver_PDO class if you use the following way
try {
$dbh = new PDO($dsn, DB_USER, DB_PASSWORD);
$dbh->exec('SET NAMES utf8');
$driver = new RedBean_Driver_PDO($dbh);
} catch (PDOException $e) {
echo 'Connection failed: ' . $e->getMessage();
}
$comments = $driver->GetAll($sql);
echo "<pre>";
die(print_r($comments));
But Still same output
["comment_content"]=> "تجربة ممتازة وتستØÙ‚ التكرار"
I am sure that my db support utf8 because when I am use the following code
mysql_connect(DB_HOST, DB_USER, DB_PASSWORD) or die(mysql_error());
mysql_select_db(DB_NAME) or die(mysql_error());
$sql = "select * from comments";
$result = mysql_query($sql) ;
while ($row = mysql_fetch_array($result)) {
echo "<pre>";
(print_r($row));
}
I am getting correct data as
[comment_content] => تجربة ممتازة وتستحق التكرار
I am also trying
R::exec('SET NAMES utf8');
But still no hope so , How can I set that encoding to support Arabic content?