Download the PHP package mapsight/pulp-pdo without Composer
On this page you can find all versions of the php package mapsight/pulp-pdo. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package pulp-pdo
Pulp PDO
Database source and destination handlers for Pulp pipelines, via PDO.
Features
- Write rows: Insert each file's rows into a table in one transaction, optionally replacing all rows or the rows of one source first. Readers never see half a file.
- Custom writes: Run your own statements per file inside a transaction.
- Query rows: Emit the result of a query as a file, to merge stored state into a pipeline.
- Lazy connections: Pass a
PDOor a callback that opens one on first use.
Installation
Write Rows
write() inserts rows into a table that already exists. It does not create or change the table: create it beforehand, or in the setUp option.
Each incoming file's content must be a list of rows, each an array of column names to values:
- Every row of a file needs the same columns, in any order.
- Values may be strings, numbers,
null, booleans (stored as0/1) or arrays (stored as JSON). - Content that does not fit fails the file like a database error does: its transaction is rolled back and the run stops. With
skipExceptions, the error is logged and the next file follows.
A Pulp::map() usually turns decoded data into rows:
Options:
replace: delete rows before inserting, in the same transaction.truedeletes every row of the table; a callback returns the column values of the rows to delete.chunkSize: rows perINSERTstatement (default100).setUp: a callback run once with the connection before the first write, outside any transaction. Create tables here: MySQL commits a transaction onCREATE TABLE.skipExceptions: log a failing file, roll it back, and continue.logSkipExceptions:stderr,stdout, orfalse.
table may also be a callback that returns the table name for a file. Table and column names may only contain letters, digits, and underscores (schema.table is allowed).
Custom Writes
transaction() calls your callback with the connection and the file, committed when it returns and rolled back when it throws. It takes the setUp, skipExceptions and logSkipExceptions options of write():
Query Rows
query() emits one file with the rows of a query, as a list of associative arrays, after the incoming files:
The files pass through every handler, so a pipeline can continue after writing.