functions.php
Functions
from_pgsql_cursor()
Create a PostgreSQL cursor extractor using server-side cursors for memory-efficient extraction.
from_pgsql_cursor(Client $client, Sql|string $query[, array<int, mixed> $parameters = [] ]) : PostgreSqlCursorExtractor
Uses DECLARE CURSOR + FETCH to stream data without loading entire result set into memory. This is the only way to achieve true low memory extraction with PHP's ext-pgsql.
Note: Requires a transaction context (auto-started if not in one).
Parameters
- $client : Client
-
PostgreSQL client
- $query : Sql|string
-
SQL query to execute (wrapped in DECLARE CURSOR)
- $parameters : array<int, mixed> = []
-
Values bound by position to $1, $2, ... placeholders; wrap with typed() to force a specific PostgreSQL type
Return values
PostgreSqlCursorExtractorfrom_pgsql_limit_offset()
Create a PostgreSQL extractor using LIMIT/OFFSET pagination.
from_pgsql_limit_offset(Client $client, Sql|string $query[, array<int, mixed> $parameters = [] ]) : PostgreSqlLimitOffsetExtractor
Suitable for smaller datasets. For large datasets, consider using keyset pagination (from_pgsql_key_set) which is more efficient.
Parameters
- $client : Client
-
PostgreSQL client
- $query : Sql|string
-
SQL query to execute (must have ORDER BY clause)
- $parameters : array<int, mixed> = []
-
Values bound by position to $1, $2, ... placeholders; wrap with typed() to force a specific PostgreSQL type
Return values
PostgreSqlLimitOffsetExtractorfrom_pgsql_key_set()
Create a PostgreSQL extractor using keyset (cursor-based) pagination.
from_pgsql_key_set(Client $client, Sql|string $query, KeySet $keySet[, array<int, mixed> $parameters = [] ]) : PostgreSqlKeySetExtractor
More efficient than LIMIT/OFFSET for large datasets - uses indexed WHERE conditions instead of skipping rows.
Parameters
- $client : Client
-
PostgreSQL client
- $query : Sql|string
-
SQL query to execute (must have ORDER BY matching keyset columns)
- $keySet : KeySet
-
Columns to use for keyset pagination
- $parameters : array<int, mixed> = []
-
Values bound by position to $1, $2, ... placeholders; wrap with typed() to force a specific PostgreSQL type
Return values
PostgreSqlKeySetExtractorpgsql_pagination_key_asc()
pgsql_pagination_key_asc(string $column) : Key
Parameters
- $column : string
Return values
Keypgsql_pagination_key_desc()
pgsql_pagination_key_desc(string $column) : Key
Parameters
- $column : string
Return values
Keypgsql_pagination_key_set()
pgsql_pagination_key_set(Key ...$keys) : KeySet
Parameters
- $keys : Key
Return values
KeySetto_pgsql_table()
to_pgsql_table(Client $client, string $table) : PostgreSqlLoader
Parameters
- $client : Client
- $table : string
Return values
PostgreSqlLoaderto_pgsql_transaction()
Execute multiple loaders within PostgreSQL transactions.
to_pgsql_transaction(Client $client, Loader ...$loaders) : TransactionalPostgreSqlLoader
Each batch of rows is loaded in its own transaction; rows a wrapped Transformation delivers when the loader is closed (blocking operations drain there) are committed in one final transaction. If any loader fails, the open transaction is rolled back. All wrapped loaders must use the same Client instance as the wrapper - a loader holding its own Client escapes the transaction.
Parameters
- $client : Client
- $loaders : Loader
Return values
TransactionalPostgreSqlLoaderpgsql_insert_options()
Create insert options for PostgreSQL loader.
pgsql_insert_options([bool $skipConflicts = false ][, array<int, string> $conflictColumns = [] ][, null|string $conflictConstraint = null ][, array<int, string> $updateColumns = [] ]) : InsertOptions
Parameters
- $skipConflicts : bool = false
-
If true, use ON CONFLICT DO NOTHING
- $conflictColumns : array<int, string> = []
-
Column names for ON CONFLICT (columns)
- $conflictConstraint : null|string = null
-
Constraint name for ON CONFLICT ON CONSTRAINT
- $updateColumns : array<int, string> = []
-
Columns to update on conflict (empty = all non-key columns)
Return values
InsertOptionspgsql_update_options()
Create update options for PostgreSQL loader.
pgsql_update_options(array<int, string> $primaryKeys) : UpdateOptions
Parameters
- $primaryKeys : array<int, string>
-
Columns to use in WHERE clause for matching rows
Return values
UpdateOptionspgsql_delete_options()
Create delete options for PostgreSQL loader.
pgsql_delete_options(array<int, string> $primaryKeys) : DeleteOptions
Parameters
- $primaryKeys : array<int, string>
-
Columns to use in WHERE clause for matching rows
Return values
DeleteOptionsto_pgsql_schema_table()
Convert a Flow Schema into a PostgreSQL table definition.
to_pgsql_schema_table(Schema $schema, string $tableName[, string $databaseSchema = 'public' ][, EntryTypesMap|null $typesMap = null ][, TableOptions|null $options = null ]) : Table
Parameters
- $schema : Schema
- $tableName : string
- $databaseSchema : string = 'public'
-
PostgreSQL schema (namespace) the table belongs to
- $typesMap : EntryTypesMap|null = null
- $options : TableOptions|null = null
-
table-level options the Flow Schema cannot express (e.g. UNLOGGED)
Return values
Tablepgsql_table_to_flow_schema()
Convert a PostgreSQL table definition into a Flow Schema.
pgsql_table_to_flow_schema(Table $table[, EntryTypesMap|null $typesMap = null ]) : Schema
Parameters
- $table : Table
- $typesMap : EntryTypesMap|null = null
Return values
Schemapgsql_schema_sort_by_type()
pgsql_schema_sort_by_type([EntryTypesMap|null $typesMap = null ]) : TypeStrategy
Parameters
- $typesMap : EntryTypesMap|null = null