加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – Doctrine 2.1和表utf-8编码

发布时间:2020-12-13 22:37:04 所属栏目:PHP教程 来源:网络整理
导读:有人能告诉我如何强制Doctrine使用UTF-8编码和utf8_polish_ci创建数据库表吗?我的Doctrine配置文件有这个db配置参数: $conn = array( 'driver' = 'pdo_mysql','dbname' = 'test','user' = 'root','password' = '*****','charset' = 'utf8','driverOptions'
有人能告诉我如何强制Doctrine使用UTF-8编码和utf8_polish_ci创建数据库表吗?我的Doctrine配置文件有这个db配置参数:
$conn = array(
    'driver' => 'pdo_mysql','dbname' => 'test','user' => 'root','password' => '*****','charset' => 'utf8','driverOptions' => array(1002=>'SET NAMES utf8'));

尽管如此,它仍然使用默认编码创建表:latin1和latin1_swedish_ci.

您在数据库中设置它,doctrine只使用数据库默认值.请参阅 Doctrine 2.1 FAQ:中的这个问题

4.1.1. How do I set the charset and collation for MySQL tables?

You can’t set these values inside the annotations,yml or xml mapping files. To make a database work with the default charset and collation you should configure MySQL to use it as default charset,or create the database with charset and collation details. This way they get inherited to all newly created database tables and columns.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读