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

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

问题描述

如何让 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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