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

Tanks.

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

Hi'ya'all

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

if($info->protocol=='mysql')
                       {
$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` (
`uid` int(11) NOT NULL AUTO_INCREMENT,
`gid` int(11) DEFAULT NULL,
`username` text,
`password` text,
PRIMARY KEY (`uid`)
) ENGINE=InnoDB AUTO_INCREMENT=66 DEFAULT CHARSET=utf8

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 http://www.phpactiverecord.org/projects/main/wiki/Conventions
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,
Code
$user = new Users;
$user->username="Cộng hòa xã hội chủ nghĩa việt nam";
$user->password='123456';
$user->save();

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
Pass:6151

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 ';'.

Example:

$config->set_connections(array(
 '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
http://blog.devdelver.com

(1-14/14)