flush
[pharext/pharext.org] / app / Cli / Initdb.php
1 <?php
2
3 namespace app\Cli;
4
5 use app\Controller;
6 use pq\Connection;
7
8 class Initdb implements Controller
9 {
10 private $pq;
11
12 function __construct(Connection $pq) {
13 $this->pq = $pq;
14 }
15
16 function __invoke(array $args = null) {
17 foreach (glob(__DIR__."/../../config/sql/*.sql") as $sql) {
18 $xa = $this->pq->startTransaction();
19 $this->pq->exec(file_get_contents($sql));
20 $xa->commit();
21 }
22 }
23 }