大网数据广告活动
PHP 语言与运行手册

pg_set_chunked_rows_size · Set the query results to be retrieved in chunk mode

· 52CE 我爱测

pg_set_chunked_rows_size — Set the query results to be retrieved in chunk mode

pg_set_chunked_rows_size

(PHP 8 >= 8.4.0)

pg_set_chunked_rows_size — Set the query results to be retrieved in chunk mode

说明

function pg_set_chunked_rows_size(PgSql\Connection $connection, int $size): bool

Set the query results to be retrieved in chunk mode. The query results returned afterward will be divided into multiple chunks, each containing up to size rows. This function must be called before retrieving results with pg_get_result(). This function is only available when libpq is version 17 or higher.

参数

connection

PgSql\Connection 实例。

size

The number of rows to be retrieved in each chunk.

返回值

成功时返回 true, 或者在失败时返回 false。

错误/异常

If size is less than 1, a ValueError will be thrown.

示例

示例 #1 pg_result_memory_size() example

<?php

$conn = pg_connect($conn_str);

for ($i = 0; $i < 10; $i ++) {
  pg_query($conn, "INSERT INTO users DEFAULT VALUES");
}

pg_send_query($conn, "SELECT * FROM users");
pg_set_chunked_rows_size($conn, 1);

$result = pg_get_result($conn);
var_dump(pg_num_rows($result));

// No effect after the result is retrieved
var_dump(pg_set_chunked_rows_size($conn, 10));

以上示例会输出:

int(1)
bool(false)

参见

来源:PHP Documentation Group · 作者与贡献记录 · CC BY 3.0。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
PHP Documentation Group
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。