Create TABLE `table` ( `id` INT( 10 ) NOT NULL , `name` VARCHAR( 50 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , INDEX ( `g_id` ) ) ENGINE = innodb CHARACTER SET utf8 COLLATE utf8_general_ci;
PHP: 存储操作指定使用utf8字符集进行连接校对,读取操作指定使用gbk字符集进行连接校对。
PHP代码:
复制代码 代码如下:
<?php // Select DB And Set Link Use UTF8 function _select_db_utf() { mysql_select_db($this->db_name, $this->db_link);
// init character mysql_query("SET NAMES utf8", $this->db_link); mysql_query("SET CHARACTER SET utf8", $this->db_link); mysql_query("SET COLLATION_CONNECTION='utf8_general_ci'", $this->db_link);
return true; }
// Select DB And Set Link Use GBK function _select_db_gb() { mysql_select_db($this->db_name, $this->db_link);