如何让 PDO 适配器在每次连接时都运行 SET NAMES utf8,在 ZendFramework 中.我正在使用 INI 文件来保存适配器配置数据.我应该在那里添加哪些条目?
How to make PDO adapter run SET NAMES utf8 each time I connect, In ZendFramework. I am using an INI file to save the adapter config data. what entries should I add there?
如果不清楚,我会在我的项目的 config.ini 文件中寻找正确的语法,而不是在 php 代码中,因为我认为这部分是配置代码.
If it wasn't clear, I am looking for the correct syntax to do it in the config.ini file of my project and not in php code, as I regard this part of the configuration code.
Itay,
一个很好的问题.幸运的是,答案很简单:
A very good question. Fortunately for you the answer is very simple:
database.params.driver_options.1002 = "SET NAMES utf8"
1002 是常量 PDO::MYSQL_ATTR_INIT_COMMAND 的值
1002 is the value of constant PDO::MYSQL_ATTR_INIT_COMMAND
你不能在 config.ini 中使用常量
You can't use the constant in the config.ini
这篇关于在 ZendFramework 中,如何让 PDO 每次连接时都运行 SET NAMES utf8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
MySQLi准备好的语句&foreach 循环MySQLi prepared statement amp; foreach loop(MySQLi准备好的语句amp;foreach 循环)
mysqli_insert_id() 是从整个服务器还是从同一用户获Is mysqli_insert_id() gets record from whole server or from same user?(mysqli_insert_id() 是从整个服务器还是从同一用户获取记录?)
PHP MySQLi 无法识别登录信息PHP MySQLi doesn#39;t recognize login info(PHP MySQLi 无法识别登录信息)
mysqli_select_db() 需要 2 个参数mysqli_select_db() expects exactly 2 parameters(mysqli_select_db() 需要 2 个参数)
Php mysql pdo 查询:用查询结果填充变量Php mysql pdo query: fill up variable with query result(Php mysql pdo 查询:用查询结果填充变量)
MySQLI 28000/1045 用户“root"@“localhost"的访问MySQLI 28000/1045 Access denied for user #39;root#39;@#39;localhost#39;(MySQLI 28000/1045 用户“root@“localhost的访问被拒绝)