引用 MySQL 文档 - mysql_set_character_set()
:
This function works like the SET NAMES statement, but also sets the value of mysql->charset, and thus affects the character set used by
mysql_real_escape_string()
当它说“works like the SET NAMES
statements”时,是否意味着实际 MySQL查询SET NAMES
将被发送到服务器?
或者这是否意味着mysql_set_character_set
的功能模仿查询SET NAMES
但不会从网络发送实际的消息或数据服务器到数据库服务器?
最佳答案
来自the manual (我的重点):
•
SET NAMES 'charset_name' [COLLATE 'collation_name']
SET NAMES
indicates what character set the client will use to send SQL statements to the server. Thus,SET NAMES 'cp1251'
tells the server, “future incoming messages from this client are in character set cp1251.” It also specifies the character set that the server should use for sending results back to the client. (For example, it indicates what character set to use for column values if you use a SELECT statement.)
如果SET NAMES
命令影响从服务器到客户端的通信中使用的字符集,则必须以某种方式将该字符集信息传输到服务器。
所以,是的。此函数调用将导致数据传输到服务器。
关于mysql - "mysql_set_character_set"是否将字节传输到MySQL服务器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26453967/