Roberto Blanes Sun Aug 22 05:03:03 -0400 2010

Subject: set_encoding($charset)

Hi, great work.

How I set de charset to utf-8?

Kien La Sun Aug 22 11:50:56 -0400 2010
Roberto Blanes Sun Aug 22 16:12:16 -0400 2010

Hi guys.

Your solution don't work for me.

I added a line in the Connection class __contruct

$this->connection->query("SET NAMES 'utf8';");

It's working fine now.

Thanks anyway

Kien La Sun Aug 22 16:44:09 -0400 2010

You're probably not using the most recent version then. You'll need the latest for it to work.

Roberto Blanes Mon Aug 23 01:25:56 -0400 2010


Danniel Korotkin Sun Jan 23 15:35:17 -0500 2011


i think that should add validation for mysql also;
active-records\lib\connection.php (line 203)
if($info->protocol=='mysql') {
$this->connection->query("SET NAMES 'utf8';");
$this->connection->query("SET CHARACTER SET utf8;");

Captain Future Mon Jan 24 09:20:49 -0500 2011

Thank u very much

Danniel Korotkin Wed Feb 02 06:17:40 -0500 2011

no problem - i have found another problems so i extend little

$this->connection->query("SET NAMES 'utf8'");
$this->connection->query("SET CHARACTER SET utf8");
$this->connection->query("SET character_set_connection=utf8");
$this->connection->query("SET character_set_client=utf8");
Quy Hai Pham Wed Aug 24 03:54:04 -0400 2011

I don't work.Please help me !

view uf8 is ok !
But insert to database not work

Danniel Korotkin Wed Aug 24 05:40:39 -0400 2011

Check your mysql what is the column charsets and also check if you sending to mysql as default utf-8

Quy Hai Pham Wed Aug 24 06:44:32 -0400 2011

My database

CREATE TABLE `users` (
`gid` int(11) DEFAULT NULL,
`username` text,
`password` text,

Can you give me your application for a test !

Thank you !

Danniel Korotkin Wed Aug 24 06:57:25 -0400 2011

First, i think you should read
uid = should be id
gid = group_id
users = people

2nd, ALTER TABLE `users` CHARACTER SET = utf8 , COLLATE = utf8_general_ci ;

Quy Hai Pham Wed Aug 24 07:15:55 -0400 2011

not work

`username` text CHARACTER SET utf8,
`password` text CHARACTER SET utf8,
$user = new Users;
$user->username="Cộng hòa xã hội chủ nghĩa việt nam";

view database "C?ng h?a x? h?i ch? ngh?a vi?t nam"
Can You help me ? You can send me your test to email:
You can remote my desktop with teamviewer!
ID:868 417 770

Thank you very much !

Quy Hai Pham Wed Aug 24 08:26:08 -0400 2011

Thanh you !
I have done !

I update activerecord 1.0rc1

Sergio Figueiredo Mon Dec 26 15:56:55 -0500 2011

December 26, 2011
The wiki's entry by Kien La does not work to me.

Solution: Change '?' delimiter to ';'.


 'development' => 'mysql://user:pass@localhost/mydb;charset=utf8')

Now, it works fine!

ref.: PHP ActiveRecord Version 1.0 - June 27, 2010

Sergio M C Figueiredo

Claus Pfisterer Sun Nov 04 05:51:58 -0500 2012

I recently had the same problem. I updated the phpactiverecord version from stable to nightly build (php-activerecord-20120801). On my local environment i use ubuntu server 12.04 (php version 5.3.10, mysql 5.5.24, apache2) and had no problems with utf8 content. but when i published on a red hat server, it failed to show utf8 content.

my connection configuration was:

'production' => 'mysql://user:/mydatabase;charset=utf8;');

i then read the forum, tried several things an the found the solution to change the configuration to this:

'production' => 'mysql://user:/mydatabase?charset=utf8');

now it works on both systems. Hope this helps you guys.

asava samuel Thu Mar 07 16:50:49 -0500 2013


Here is an ORM that works with MySQL