commit | author | age
|
ced309
|
1 |
<?php |
JK |
2 |
if(php_sapi_name() !== 'cli') die(); |
|
3 |
|
|
4 |
include('stops.php'); |
|
5 |
include('common.php'); |
|
6 |
|
|
7 |
$pdo = new PDO('sqlite:stops_temp.db'); |
|
8 |
|
|
9 |
$pdo->query('DROP TABLE IF EXISTS stop_search'); |
|
10 |
$pdo->query('CREATE TABLE stop_search ( |
|
11 |
word VARCHAR(60), |
|
12 |
id INT |
|
13 |
)'); |
|
14 |
|
|
15 |
$pdo->beginTransaction(); |
|
16 |
$st = $pdo->prepare('INSERT INTO stop_search (word, id) VALUES (?, ?)'); |
|
17 |
foreach($stops as $id => $name) { |
|
18 |
foreach(split_stop_name($name) as $word) { |
|
19 |
$st->execute(array($word, $id)); |
|
20 |
$st->closeCursor(); |
|
21 |
} |
|
22 |
} |
|
23 |
$pdo->commit(); |
|
24 |
|
|
25 |
$pdo->query('CREATE INDEX stop_search_word ON stop_search (word COLLATE NOCASE)'); |
|
26 |
|
|
27 |
rename('stops_temp.db', 'stops.db'); |