每当我连接时,如何使PDO在SET中运行SET NAMES utf8,在ZendFramework中 [英] How to make PDO run SET NAMES utf8 each time I connect, In ZendFramework

查看:82
本文介绍了每当我连接时,如何使PDO在SET中运行SET NAMES utf8,在ZendFramework中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每次在ZendFramework中连接时,如何使PDO适配器运行SET NAMES utf8. 我正在使用一个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

这篇关于每当我连接时,如何使PDO在SET中运行SET NAMES utf8,在ZendFramework中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆