©
Dokumen ini menggunakan Manual laman web PHP Cina Lepaskan
下列常量由此扩展定义,且仅在此扩展编译入 PHP 或在运行时动态载入时可用。
在 PHP 4.3.0 以后的版本中,允许在 mysql_connect() 函数和 mysql_pconnect() 函数中指定更多的客户端标记。下面列出所定义的常量:
常量 | 说明 |
---|---|
MYSQL_CLIENT_COMPRESS | 使用压缩的通讯协议 |
MYSQL_CLIENT_IGNORE_SPACE | 允许在函数名后留空格位 |
MYSQL_CLIENT_INTERACTIVE | 允许设置断开连接之前所空闲等候的 interactive_timeout 时间(代替 wait_timeout)。 |
MYSQL_CLIENT_SSL | 使用 SSL 加密。本标志仅在 MySQL 客户端库版本为 4.x 或更高版本时可用。在 PHP 4 和 Windows 版的 PHP 5 安装包中绑定的都是 3.23.x。 |
mysql_fetch_array() 函数使用一个常量来表示所返回数组的类型。下面是常量的定义:
常量 | 说明 |
---|---|
MYSQL_ASSOC | 返回的数据列使用字段名作为数组的索引名。 |
MYSQL_BOTH | 返回的数据列使用字段名及数字索引作为数组的索引名。 |
MYSQL_NUM | 返回的数据列使用数字索引作为数组的索引名。索引从 0 开始,表示返回结果的第一个字段。 |
[#1] frak at gingerhq dot net [2011-06-30 11:06:00]
If you're using stored procedures and mysql_error() returns "PROCEDURE storedProcedureName can't return a result set in the given context", you need to pass an additional flag (CLIENT_MULTI_RESULTS) to mysql_connect() as such:
mysql_connect($hostname, $username, $password, true, 131072);
Some other sources say that you should use 65536. 65536 is actually the flag to allow multiple statements in a single mysql_query(), and is a security issue. The reason it allows you to receive results from stored procedures is because it implies 131072. To be safe, use 131072 over 65536.
[#2] pcdinh at phpvietnam dot net [2010-02-13 00:54:54]
Other client flags extracted from MySQL client source
#define CLIENT_LONG_PASSWORD 1
#define CLIENT_FOUND_ROWS 2
#define CLIENT_LONG_FLAG 4
#define CLIENT_CONNECT_WITH_DB 8
#define CLIENT_NO_SCHEMA 16
#define CLIENT_COMPRESS 32
#define CLIENT_ODBC 64
#define CLIENT_LOCAL_FILES 128
#define CLIENT_IGNORE_SPACE 256
#define CLIENT_PROTOCOL_41 512
#define CLIENT_INTERACTIVE 1024
#define CLIENT_SSL 2048
#define CLIENT_IGNORE_SIGPIPE 4096
#define CLIENT_TRANSACTIONS 8192
#define CLIENT_RESERVED 16384
#define CLIENT_SECURE_CONNECTION 32768
#define CLIENT_MULTI_STATEMENTS 65536
#define CLIENT_MULTI_RESULTS 131072
#define CLIENT_REMEMBER_OPTIONS (((ulong) 1) << 31)
[#3] Contact at LinuxIntro dot com [2008-10-27 21:33:45]
When you connect and expect to use a stored procedure,you must pass a special flag to MySQL via the connect command, otherwise you will not get the results returned, and it will result in this error:
PROCEDURE AlexGrim.GetStats_ForumCategories can't return a result set in the given context
To fix this, change you connection string, adding ",false,65536" as the last 2 fields:
$this->con = mysql_connect($this->h,$this->u,$this->p,false,65536);