File tree Expand file tree Collapse file tree 2 files changed +10
-12
lines changed Expand file tree Collapse file tree 2 files changed +10
-12
lines changed Original file line number Diff line number Diff line change 1
1
<?php
2
2
3
- use Clue \React \SQLite \Factory ;
4
- use Clue \React \SQLite \Result ;
5
-
6
3
require __DIR__ . '/../vendor/autoload.php ' ;
7
4
8
- $ factory = new Factory ();
5
+ $ factory = new Clue \ React \ SQLite \ Factory ();
9
6
10
7
$ n = isset ($ argv [1 ]) ? $ argv [1 ] : 1 ;
11
8
$ db = $ factory ->openLazy ('test.db ' );
14
11
$ promise ->then (null , 'printf ' );
15
12
16
13
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 ) {
18
15
echo 'New row ' . $ result ->insertId . PHP_EOL ;
16
+ }, function (Exception $ e ) {
17
+ echo 'Error: ' . $ e ->getMessage () . PHP_EOL ;
19
18
});
20
19
}
21
20
Original file line number Diff line number Diff line change 1
1
<?php
2
2
3
- use Clue \React \SQLite \DatabaseInterface ;
4
- use Clue \React \SQLite \Factory ;
5
- use Clue \React \SQLite \Result ;
6
-
7
3
require __DIR__ . '/../vendor/autoload.php ' ;
8
4
9
- $ factory = new Factory ();
5
+ $ factory = new Clue \ React \ SQLite \ Factory ();
10
6
11
7
$ search = isset ($ argv [1 ]) ? $ argv [1 ] : 'foo ' ;
12
8
$ db = $ factory ->openLazy ('test.db ' );
13
9
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 ) {
15
11
echo 'Found ' . count ($ result ->rows ) . ' rows: ' . PHP_EOL ;
16
12
echo implode ("\t" , $ result ->columns ) . PHP_EOL ;
17
13
foreach ($ result ->rows as $ row ) {
18
14
echo implode ("\t" , $ row ) . PHP_EOL ;
19
15
}
20
- }, 'printf ' );
16
+ }, function (Exception $ e ) {
17
+ echo 'Error: ' . $ e ->getMessage () . PHP_EOL ;
18
+ });
19
+
21
20
$ db ->quit ();
You can’t perform that action at this time.
0 commit comments