Store and secure in one of many available data sinks.
Examples:
Description
Read data from Database through Doctrine DBAL
The example below shows how to read from a single table using limit/offset extractor.
To read data from more advanced queries, you can use one of the following extractors:
// read from a single table using limit/offset pagination
from_dbal_limit_offset(
$connection,
'orders',
new OrderBy('created_at', Order::DESC),
)
// read from a query using limit/offset pagination
from_dbal_limit_offset_qb(
$connection,
$connection->createQueryBuilder()->select('*')->from('orders')
);
// read from a single query
from_dbal_query(
$connection,
'SELECT * FROM orders',
);
// read from multiple queries each time using next parameters from the provided set
from_dbal_queries(
$connection,
'SELECT * FROM orders LIMIT :limit OFFSET :offset',
new \Flow\ETL\Adapter\Doctrine\ParametersSet(
['limit' => 2, 'offset' => 0],
['limit' => 2, 'offset' => 2],
)
);
Additionally, each of them allows setting dataset schema through $extractor->withSchema(Schema $schema) method.
Code
<?php
declare(strict_types=1);
use function Flow\ETL\Adapter\Doctrine\from_dbal_limit_offset;
use function Flow\ETL\DSL\{data_frame, to_stream};
use Doctrine\DBAL\DriverManager;
use Flow\ETL\Adapter\Doctrine\{Order, OrderBy};
require __DIR__ . '/../../../autoload.php';
$connection = DriverManager::getConnection([
'path' => __DIR__ . '/input/orders.db',
'driver' => 'pdo_sqlite',
]);
data_frame()
->read(
from_dbal_limit_offset(
$connection,
'orders',
new OrderBy('created_at', Order::DESC),
)
)
->collect()
->write(to_stream(__DIR__ . '/output.txt', truncate: false))
->run();
Output
+--------------------------------------+---------------------+---------------------+----------+-----------------------------+--------------------+--------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| order_id | created_at | updated_at | discount | email | customer | address | notes | items |
+--------------------------------------+---------------------+---------------------+----------+-----------------------------+--------------------+--------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| aae4af19-4da1-3d9c-a11d-fed828cedb55 | 2024-12-10 17:59:37 | | | [email protected] | Dock Windler | {"street":"62355 Turcotte Springs Apt. 711","city":"Kiehnchester","zip":"90369-9957","country":"Cyprus"} | ["Molestias repellendus porro suscipit autem reiciendis itaque.","Aut laudantium quia temporibus fuga mollitia consectetur.","Consequatur ab aliquid perspiciatis labore animi ullam odit."] | [{"sku":"SKU_0004","quantity":2,"price":452.34},{"sku":"SKU_0002","quantity":9,"price":1.92},{"sku":"SKU_0005","quantity":1,"price":428.34},{"sku":"SKU_0005","quantity":5,"price":428.34}] |
| 69ec30d4-30e6-34d8-82cb-1fdffdba5a6a | 2024-12-05 23:07:01 | 2024-12-11 19:12:01 | 9.05 | [email protected] | Marge Tillman | {"street":"499 Lucio Island","city":"Lake Adeliaview","zip":"35362","country":"New Zealand"} | ["Esse voluptas et architecto."] | [{"sku":"SKU_0003","quantity":10,"price":274.84},{"sku":"SKU_0004","quantity":7,"price":193.93},{"sku":"SKU_0005","quantity":4,"price":420.3},{"sku":"SKU_0005","quantity":8,"price":420.3}] |
| 8c1636fa-10ae-3d45-944c-5733c4705d43 | 2024-12-04 14:32:04 | | | [email protected] | Johnpaul Kemmer | {"street":"14702 Denesik Springs Suite 186","city":"Terryfort","zip":"55100-1066","country":"United States Virgin Islands"} | ["Consectetur eum nulla asperiores et sapiente aut.","Nisi quaerat voluptatem itaque vero.","Qui quia facere sint ab minus inventore voluptatem ut.","Eveniet possimus quis omnis quisquam officia.","Et neque quia nostrum et et commodi placeat."] | [{"sku":"SKU_0005","quantity":3,"price":428.34},{"sku":"SKU_0004","quantity":7,"price":452.34},{"sku":"SKU_0005","quantity":5,"price":428.34}] |
| 8fb8430b-2890-3143-ad35-2a4ed8e3abcc | 2024-11-14 02:09:43 | 2024-12-04 17:24:55 | 42.59 | [email protected] | Burnice Williamson | {"street":"79717 Araceli Parks Suite 569","city":"East Abbyland","zip":"59282-3483","country":"Egypt"} | ["Ea ab et est tempore."] | [{"sku":"SKU_0003","quantity":9,"price":274.84}] |
| 8fd5a178-259d-3e7a-9267-a33d20e11fc6 | 2024-10-30 19:21:54 | 2024-11-22 01:55:37 | 37.07 | [email protected] | Raymond Schoen | {"street":"6166 Nolan Place","city":"East Boydview","zip":"96752-4891","country":"San Marino"} | ["Aut minima voluptas est eius maxime eveniet saepe.","Soluta accusantium eius placeat corporis quam illo.","Voluptas impedit ratione alias quis."] | [{"sku":"SKU_0003","quantity":6,"price":384.95},{"sku":"SKU_0003","quantity":2,"price":384.95},{"sku":"SKU_0005","quantity":8,"price":428.34},{"sku":"SKU_0002","quantity":1,"price":1.92}] |
| 91aaa649-1c94-31ec-814e-f9e4b1aa4259 | 2024-10-25 07:36:25 | | 13.3 | [email protected] | Favian Keebler | {"street":"3633 Nader Prairie Apt. 816","city":"Venamouth","zip":"78044-4385","country":"Greece"} | ["Delectus non eveniet commodi esse deleniti sit pariatur.","Fugit sit aut qui doloremque.","Dicta consequatur minima exercitationem qui.","Consequatur qui qui aliquid."] | [{"sku":"SKU_0002","quantity":8,"price":254.44},{"sku":"SKU_0002","quantity":4,"price":254.44},{"sku":"SKU_0003","quantity":4,"price":274.84}] |
| 8c09ba7d-94a8-37c5-b6ca-875ef71437dd | 2024-09-30 10:35:50 | | 20.45 | [email protected] | Jeremie Collier | {"street":"591 Evalyn Plains","city":"Deckowchester","zip":"30374","country":"Cyprus"} | ["Consequatur possimus provident quasi ad enim fugit repellendus."] | [{"sku":"SKU_0004","quantity":2,"price":452.34},{"sku":"SKU_0004","quantity":10,"price":452.34},{"sku":"SKU_0003","quantity":7,"price":384.95},{"sku":"SKU_0003","quantity":9,"price":384.95}] |
| 6f8579ae-b18a-35e3-800a-bc9157dbe4e8 | 2024-07-03 10:10:18 | | 42.2 | [email protected] | Cyrus Zulauf | {"street":"1566 Bergstrom Mountains","city":"Cassinshire","zip":"36420","country":"Kyrgyz Republic"} | ["Ea perferendis blanditiis ut quas veniam fugiat architecto laboriosam.","Consequuntur optio rerum reprehenderit praesentium cupiditate accusamus dolorem iusto.","Excepturi optio fugiat nobis officiis molestias nulla."] | [{"sku":"SKU_0002","quantity":1,"price":1.92},{"sku":"SKU_0002","quantity":7,"price":1.92}] |
| 48ec80e8-51c9-39ae-a5b6-d76cc1ad2ef8 | 2024-05-12 12:26:01 | | | [email protected] | Cayla Jaskolski | {"street":"58196 Crist Coves Apt. 123","city":"North Rigobertoburgh","zip":"61950","country":"United States Minor Outlying Islands"} | ["Reiciendis corporis magnam sint occaecati quia quibusdam."] | [{"sku":"SKU_0005","quantity":9,"price":420.3},{"sku":"SKU_0002","quantity":9,"price":254.44},{"sku":"SKU_0004","quantity":6,"price":193.93},{"sku":"SKU_0005","quantity":8,"price":420.3}] |
| a1d7f86a-d5ef-31cd-b90e-373375fda2b1 | 2024-05-02 12:51:29 | | 4.37 | [email protected] | Moshe Sipes | {"street":"15319 Barry Shoal","city":"West Rosalynstad","zip":"17648","country":"Jersey"} | ["Dignissimos maxime saepe inventore magni reiciendis.","Accusantium ut reiciendis incidunt."] | [{"sku":"SKU_0002","quantity":3,"price":1.92},{"sku":"SKU_0004","quantity":7,"price":452.34},{"sku":"SKU_0002","quantity":7,"price":1.92},{"sku":"SKU_0004","quantity":6,"price":452.34}] |
| 6bcdba7e-644b-3ee2-b186-e240280db85e | 2024-04-28 04:40:18 | | 40.89 | [email protected] | Amy Spinka | {"street":"3173 Callie Mount Suite 224","city":"West Winston","zip":"22316-8822","country":"Panama"} | ["Consectetur ab quod dolores commodi quam et qui.","Distinctio at qui sunt voluptas.","Perferendis vitae molestiae exercitationem odit necessitatibus quis sunt."] | [{"sku":"SKU_0002","quantity":3,"price":254.44},{"sku":"SKU_0003","quantity":3,"price":274.84}] |
| 47fd42e2-01f3-3cc1-95a4-cf3bbbfcb681 | 2024-04-14 06:34:39 | 2024-11-26 11:45:11 | 1.41 | [email protected] | Damion Schneider | {"street":"7867 Mitchell Lodge Suite 623","city":"Lake Candaceshire","zip":"84359-3572","country":"Mexico"} | ["Qui ea dignissimos qui dolor velit possimus.","Error voluptates sequi velit id ut delectus beatae."] | [{"sku":"SKU_0005","quantity":9,"price":428.34}] |
| 1f3dbdb8-9abb-3636-8009-e8554c7259f9 | 2024-03-01 05:58:59 | 2024-11-20 05:38:10 | 7.53 | [email protected] | Vinnie Stoltenberg | {"street":"5314 Renner Fort","city":"Melyssafort","zip":"26563-5133","country":"Gabon"} | ["Excepturi necessitatibus voluptatibus sint eligendi qui fugit.","Eveniet quia aut dolores.","Eos mollitia quia consectetur eius quibusdam dicta.","Eius ea corrupti quia dolore."] | [{"sku":"SKU_0005","quantity":10,"price":428.34}] |
| 4bc773e2-7177-319b-bc1d-f153d6d252d7 | 2024-03-01 02:24:09 | 2024-11-22 13:30:21 | 0.74 | [email protected] | Penelope Hyatt | {"street":"62745 Stracke View Apt. 564","city":"Ethylport","zip":"62968","country":"Martinique"} | ["Deleniti officia perspiciatis aut.","Qui fugiat sed sunt.","Officiis est officiis blanditiis et doloribus aut sed vel.","Et possimus ea deleniti.","Aspernatur provident deleniti excepturi accusantium ut est aut."] | [{"sku":"SKU_0005","quantity":5,"price":428.34},{"sku":"SKU_0005","quantity":7,"price":428.34},{"sku":"SKU_0003","quantity":8,"price":384.95}] |
| b9ce9552-0700-311b-bf84-fbdb6c908705 | 2024-02-24 20:53:52 | 2024-11-23 14:25:06 | 41.05 | [email protected] | Alfreda Lebsack | {"street":"632 Simonis Corner","city":"Aldaville","zip":"56238","country":"Tonga"} | ["Quisquam id eum est quos fugiat ut repellendus."] | [{"sku":"SKU_0005","quantity":9,"price":420.3},{"sku":"SKU_0005","quantity":5,"price":420.3}] |
| 1c8fed59-abf4-3940-bd9a-8ceaf4f2c086 | 2024-01-26 08:59:04 | | | [email protected] | April Bayer | {"street":"5324 Lesch Locks","city":"Martinaburgh","zip":"33762-4863","country":"Somalia"} | ["Assumenda aut sint sint aspernatur.","Similique exercitationem ea ipsam porro aut ea culpa.","Voluptatem cupiditate tempore ea explicabo minus fuga voluptatem.","Ea distinctio libero qui qui ut enim placeat quod.","Iusto blanditiis ab molestiae."] | [{"sku":"SKU_0005","quantity":1,"price":420.3},{"sku":"SKU_0004","quantity":7,"price":193.93},{"sku":"SKU_0002","quantity":5,"price":254.44}] |
| d9bf75fa-de71-3f7e-8719-e09b2c83c090 | 2024-01-20 17:07:56 | | 27.73 | [email protected] | Ethelyn Jakubowski | {"street":"9611 Aufderhar Summit","city":"West Cristopherville","zip":"45440","country":"Saint Lucia"} | ["Quo suscipit pariatur quod dolore vel ratione consequatur quibusdam.","Dolorem at sequi ut hic."] | [{"sku":"SKU_0005","quantity":10,"price":420.3},{"sku":"SKU_0002","quantity":5,"price":254.44}] |
| 81534cff-ce51-3e6c-a1e0-95c7f19a372b | 2024-01-20 11:57:25 | 2024-11-25 17:16:17 | | [email protected] | Samara Mitchell | {"street":"60403 Johnson Drive","city":"North Leannemouth","zip":"95357","country":"Uruguay"} | ["Omnis omnis voluptatem id asperiores beatae voluptatum nesciunt aut.","Excepturi nisi eos assumenda rerum id.","Eligendi aut ipsam fugiat ducimus explicabo voluptate.","Ipsum qui nam accusantium.","Nemo ut cupiditate perferendis vitae quaerat accusantium sint."] | [{"sku":"SKU_0002","quantity":2,"price":254.44}] |
| 2e2ca445-35fa-31ab-b682-94e919456df1 | 2024-01-09 22:08:01 | | 43.35 | [email protected] | Erwin Lockman | {"street":"195 Weber Greens Suite 302","city":"Tylermouth","zip":"89977-7826","country":"Iceland"} | ["Exercitationem dolor praesentium ut ad.","Et eius tenetur illo et sint.","Maxime maxime natus ipsa numquam aut voluptas voluptatum."] | [{"sku":"SKU_0004","quantity":4,"price":193.93},{"sku":"SKU_0004","quantity":6,"price":193.93}] |
| b3397d3c-d9c3-3163-80c4-2541d91d3638 | 2024-01-09 09:23:58 | 2024-12-02 19:23:42 | | [email protected] | Ima McCullough | {"street":"4820 Goyette Flats Apt. 496","city":"East Eleanorefort","zip":"12844-7740","country":"Falkland Islands (Malvinas)"} | ["Id quaerat saepe blanditiis pariatur quia repudiandae quam maxime.","Aut at qui tempora exercitationem."] | [{"sku":"SKU_0002","quantity":3,"price":1.92},{"sku":"SKU_0002","quantity":7,"price":1.92}] |
+--------------------------------------+---------------------+---------------------+----------+-----------------------------+--------------------+--------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
20 rows