phpLens
 home  products examples manual  faq support forum  contact news  login store

Forums: phplens   adodb
Forums:   ADOdb Help & Dev:   Replies 
New ReplySearch
Topic: ADOdb + UTF-8 + MySQL
author: Joseph Lopez   created: 12-04-2012 09:14:56 PM
Hello,

I am developing a project in PHP, and I am using ADOdb to communicate with my MySQL database. The database is all configured to use UTF-8.

If I insert MySQL by hand, simply by:
mysql_select_db($database) or die( "Unable to select database");
mysql_set_charset('utf8');
mysql_query($query);

I have no encoding problems, and all characters (e.g., '
Topic: Re:ADOdb + UTF-8 + MySQL
author: John Lim   created: 01-05-2012 11:00:55 PM
Hi,

Please add following function to adodb-mysql.inc.php. I have not fully tested it but it looks ok:

function SetCharSet($charset_name)
{
if (!function_exists('mysql_set_charset'))
return false;

if ($this->charSet !== $charset_name) {
$ok = @mysql_set_charset($charset_name,$this->_connectionID);
if ($ok) {
$this->charSet = $charset_name;
return true;
}
return false;
}
return true;
}
Topic: Re:ADOdb + UTF-8 + MySQL
author: John Lim   created: 01-05-2012 11:43:57 PM
Forgot to mention, place in connection class, and use as follows:

$db->SetCharSet('utf8');
Page 1
New ReplySearch

View Source

email: contact#phplens.com (change # to @)     telephone (malaysia): 60-3-7947 2888     fax (malaysia): 60-3-7947 2800