From acb91034693bf79542681e445808bc12d254a0b7 Mon Sep 17 00:00:00 2001 From: Volodymyr Pasika Date: Tue, 25 Jun 2019 14:13:51 +0300 Subject: [PATCH 1/5] transaction --- .idea/php.xml | 4 +++ .idea/vcs.xml | 6 +++++ example/export_from_database_via_pdo.php | 32 +++++++++++++++++------- 3 files changed, 33 insertions(+), 9 deletions(-) create mode 100644 .idea/php.xml create mode 100644 .idea/vcs.xml diff --git a/.idea/php.xml b/.idea/php.xml new file mode 100644 index 0000000..0151495 --- /dev/null +++ b/.idea/php.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/example/export_from_database_via_pdo.php b/example/export_from_database_via_pdo.php index ee0d6ae..18d8210 100644 --- a/example/export_from_database_via_pdo.php +++ b/example/export_from_database_via_pdo.php @@ -9,16 +9,30 @@ $pdo = new PDO('mysql:host=localhost;dbname=test', 'root', 'root'); -$pdo->query('CREATE TABLE IF NOT EXISTS user (id INT, `name` VARCHAR(255), email VARCHAR(255))'); -$pdo->query("INSERT INTO user VALUES(1, 'alice', 'alice@example.com')"); -$pdo->query("INSERT INTO user VALUES(2, 'bob', 'bob@example.com')"); -$pdo->query("INSERT INTO user VALUES(3, 'carol', 'carol@example.com')"); +try{ -$config = new ExporterConfig(); -$exporter = new Exporter($config); + $pdo->beginTransaction(); -$stmt = $pdo->prepare("SELECT * FROM user"); -$stmt->execute(); + $pdo->commit(); + + $pdo->query('CREATE TABLE IF NOT EXISTS user (id INT, `name` VARCHAR(255), email VARCHAR(255))'); + $pdo->query("INSERT INTO user VALUES(1, 'alice', 'alice@example.com')"); + $pdo->query("INSERT INTO user VALUES(2, 'bob', 'bob@example.com')"); + $pdo->query("INSERT INTO user VALUES(3, 'carol', 'carol@example.com')"); + + $config = new ExporterConfig(); + $exporter = new Exporter($config); + + $stmt = $pdo->prepare("SELECT * FROM user"); + $stmt->execute(); + + $exporter->export('php://output', new PdoCollection($stmt)); + +} catch(Exception $e) { + + echo $e->getMessage(); + $pdo->rollBack(); + +} -$exporter->export('php://output', new PdoCollection($stmt)); From c841754e4b88c645fe2218c98abb43e20b85613f Mon Sep 17 00:00:00 2001 From: Volodymyr Pasika Date: Tue, 25 Jun 2019 14:14:22 +0300 Subject: [PATCH 2/5] idea removed --- .idea/csv.iml | 10 ++ .idea/misc.xml | 6 + .idea/modules.xml | 8 ++ .idea/php.xml | 4 - .idea/vcs.xml | 6 - .idea/workspace.xml | 333 ++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 357 insertions(+), 10 deletions(-) create mode 100644 .idea/csv.iml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml delete mode 100644 .idea/php.xml delete mode 100644 .idea/vcs.xml create mode 100644 .idea/workspace.xml diff --git a/.idea/csv.iml b/.idea/csv.iml new file mode 100644 index 0000000..77098d0 --- /dev/null +++ b/.idea/csv.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..28a804d --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..a930767 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/php.xml b/.idea/php.xml deleted file mode 100644 index 0151495..0000000 --- a/.idea/php.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..2319494 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,333 @@ + + + + + + + + + + + $PROJECT_DIR$/composer.json + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + fputcsv + addObserver + + + $PROJECT_DIR$/src + $PROJECT_DIR$ + + + + + + + + + + + true + DEFINITION_ORDER + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - 1561454082442 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file From a8426e394841bb143d2bdbbe8711d969734bdce8 Mon Sep 17 00:00:00 2001 From: Volodymyr Pasika Date: Tue, 25 Jun 2019 14:25:04 +0300 Subject: [PATCH 4/5] formating fix --- .idea/csv.iml | 10 + .idea/misc.xml | 6 + .idea/modules.xml | 8 + .idea/php.xml | 4 + .idea/vcs.xml | 6 + .idea/workspace.xml | 322 +++++++++++++++++++++++ example/export_from_database_via_pdo.php | 28 +- 7 files changed, 370 insertions(+), 14 deletions(-) create mode 100644 .idea/csv.iml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/php.xml create mode 100644 .idea/vcs.xml create mode 100644 .idea/workspace.xml diff --git a/.idea/csv.iml b/.idea/csv.iml new file mode 100644 index 0000000..77098d0 --- /dev/null +++ b/.idea/csv.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..28a804d --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..a930767 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/php.xml b/.idea/php.xml new file mode 100644 index 0000000..0151495 --- /dev/null +++ b/.idea/php.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..f7cb115 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,322 @@ + + + + + + + + + $PROJECT_DIR$/composer.json + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + fputcsv + addObserver + + + $PROJECT_DIR$/src + $PROJECT_DIR$ + + + + + + + + + + + true + DEFINITION_ORDER + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - 1561454082442 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/example/export_from_database_via_pdo.php b/example/export_from_database_via_pdo.php index 510bfce..99b0920 100644 --- a/example/export_from_database_via_pdo.php +++ b/example/export_from_database_via_pdo.php @@ -9,7 +9,7 @@ $pdo = new PDO('mysql:host=localhost;dbname=test', 'root', 'root'); -try{ +try { $pdo->beginTransaction(); @@ -32,7 +32,7 @@ echo $e->getMessage(); $pdo->rollBack(); - + }