php – Doctrine 2.1和表utf-8编码

前端之家收集整理的这篇文章主要介绍了php – Doctrine 2.1和表utf-8编码前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
有人能告诉我如何强制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.

原文链接:https://www.f2er.com/php/133604.html

猜你在找的PHP相关文章