-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathsearch.php
More file actions
20 lines (15 loc) · 617 Bytes
/
search.php
File metadata and controls
20 lines (15 loc) · 617 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?php
require __DIR__ . '/../vendor/autoload.php';
$factory = new Clue\React\SQLite\Factory();
$db = $factory->openLazy(__DIR__ . '/users.db');
$search = isset($argv[1]) ? $argv[1] : '';
$db->query('SELECT * FROM user WHERE name LIKE ?', ['%' . $search . '%'])->then(function (Clue\React\SQLite\Result $result) {
echo 'Found ' . count($result->rows) . ' rows: ' . PHP_EOL;
echo implode("\t", $result->columns) . PHP_EOL;
foreach ($result->rows as $row) {
echo implode("\t", $row) . PHP_EOL;
}
}, function (Exception $e) {
echo 'Error: ' . $e->getMessage() . PHP_EOL;
});
$db->quit();