PHP 8.4.1 Released!

pg_set_chunked_rows_size

(PHP 8 >= 8.4.0)

pg_set_chunked_rows_sizeSet the query results to be retrieved in chunk mode

Description

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.

Liste de paramètres

connection

Une instance PgSql\Connection.

size
The number of rows to be retrieved in each chunk.

Valeurs de retour

Cette fonction retourne true en cas de succès ou false si une erreur survient.

Erreurs / Exceptions

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

Exemples

Exemple #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));

L'exemple ci-dessus va afficher :

int(1)
bool(false)

Voir aussi

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top