Skip to content

Commit ae22bfb

Browse files
committed
Improve examples and use full namespaces
1 parent 6be9d55 commit ae22bfb

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

examples/insert.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
<?php
22

3-
use Clue\React\SQLite\Factory;
4-
use Clue\React\SQLite\Result;
5-
63
require __DIR__ . '/../vendor/autoload.php';
74

8-
$factory = new Factory();
5+
$factory = new Clue\React\SQLite\Factory();
96

107
$n = isset($argv[1]) ? $argv[1] : 1;
118
$db = $factory->openLazy('test.db');
@@ -14,8 +11,10 @@
1411
$promise->then(null, 'printf');
1512

1613
for ($i = 0; $i < $n; ++$i) {
17-
$db->exec("INSERT INTO foo (bar) VALUES ('This is a test')")->then(function (Result $result) {
14+
$db->exec("INSERT INTO foo (bar) VALUES ('This is a test')")->then(function (Clue\React\SQLite\Result $result) {
1815
echo 'New row ' . $result->insertId . PHP_EOL;
16+
}, function (Exception $e) {
17+
echo 'Error: ' . $e->getMessage() . PHP_EOL;
1918
});
2019
}
2120

examples/search.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
<?php
22

3-
use Clue\React\SQLite\DatabaseInterface;
4-
use Clue\React\SQLite\Factory;
5-
use Clue\React\SQLite\Result;
6-
73
require __DIR__ . '/../vendor/autoload.php';
84

9-
$factory = new Factory();
5+
$factory = new Clue\React\SQLite\Factory();
106

117
$search = isset($argv[1]) ? $argv[1] : 'foo';
128
$db = $factory->openLazy('test.db');
139

14-
$db->query('SELECT * FROM foo WHERE bar LIKE ?', ['%' . $search . '%'])->then(function (Result $result) {
10+
$db->query('SELECT * FROM foo WHERE bar LIKE ?', ['%' . $search . '%'])->then(function (Clue\React\SQLite\Result $result) {
1511
echo 'Found ' . count($result->rows) . ' rows: ' . PHP_EOL;
1612
echo implode("\t", $result->columns) . PHP_EOL;
1713
foreach ($result->rows as $row) {
1814
echo implode("\t", $row) . PHP_EOL;
1915
}
20-
}, 'printf');
16+
}, function (Exception $e) {
17+
echo 'Error: ' . $e->getMessage() . PHP_EOL;
18+
});
19+
2120
$db->quit();

0 commit comments

Comments
 (0)