数据库字符集

浏览:1502 发布日期:2016/08/27 分类:求助交流 关键字: 数据库
我的A数据库编码方式是GBK,而我的网页代码编码方式为UTF-8,在配置中设置了 'DB_CHARSET'=> 'gbk', // 字符集
但是还是访问不到
控制器login方法
public function login(){
$_COOKIE['username']="123";
//echo $_COOKIE['username'];
//使用M方法实例化
$login = M('UcenterMembers');
//执行其他的数据操作
$list=$login->scope('findusername')->select();
$this->assign('list',$list);
$this->display();
模型:
<?php
namespace Home\Model;
use Think\Model;
//CommonMemberModel连接的是think_common_member表需要改变数据库表前缀
class UcenterMembersModel extends Model{
protected $tablePrefix = 'pre_';//更改数据库表前缀为pre

//定义模型类的scope属性?
protected $_scope =array(
// 命名范围username(查找pre_ucenter_members)
'findusername'=>array(
'where'=>array('username'=>'{$_COOKIE['username']}'),
'field'=>'username,password,uid',
),
)
}

?>
视图:
<!DOCTYPE html>
<html>
<head>
<meta charset="gb2321">
<title>hello</title>
</head>
<body>
{$list}
</body>
</html>
最佳答案
评论( 相关
后面还有条评论,点击查看>>