PDO::pgsqlCopyToArray

(PHP 5 >= 5.3.3, PHP 7, PHP 8)

PDO::pgsqlCopyToArrayCopy data from database table into PHP array

Description

public PDO::pgsqlCopyToArray(
    string $table_name,
    string $delimiter = "\t",
    string $null_as = "\\\\N",
    string $fields = ?
): array|false

Copies data from table into array using delimiter as fields delimiter and fields list

Parameters

table_name

String containing table name

delimiter

Delimiter used in rows

null_as

How to interpret null values

fields

List of fields to export

Return Values

Returns an array of rows, or false on failure.

add a note

User Contributed Notes 1 note

up
0
Hayley Watson
6 years ago
The "rows" returned are strings, (hence the delimiter parameters for separating fields). They're not parsed into PHP arrays, so this isn't a substitute for $connection->query('SELECT * FROM table_name')->fetchAll().

Only the first character of $delimiter is used. Characters that may be used are those <32 except "\r", "\n" and NUL (chr(0)); anything from !"#$%&'()*+,-./:;<=>?@ABCDEFGHIJKMOPQRSTVWXYZ[]^_`{|}~, and DEL (chr(127)) (yes, upper-case letters are allowed, but lower-case ones are not).

Also, the $fields argument is a comma-separated list of the desired columns.
To Top