1 | <?php |
2 | |
3 | class Bd |
4 | { |
5 | |
6 | private static ?PDO $pdo = null; |
7 | |
8 | static function pdo(): PDO |
9 | { |
10 | if (self::$pdo === null) { |
11 | self::$pdo = new PDO( |
12 | |
13 | "sqlite:sincronizacion.db", |
14 | |
15 | null, |
16 | |
17 | null, |
18 | |
19 | [PDO::ATTR_PERSISTENT => false, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION] |
20 | ); |
21 | |
22 | self::$pdo->exec( |
23 | 'CREATE TABLE IF NOT EXISTS PASATIEMPO ( |
24 | PAS_ID TEXT NOT NULL, |
25 | PAS_NOMBRE TEXT NOT NULL, |
26 | PAS_MODIFICACION INTEGER NOT NULL, |
27 | PAS_ELIMINADO INTEGER NOT NULL, |
28 | CONSTRAINT PAS_PK |
29 | PRIMARY KEY(PAS_ID), |
30 | CONSTRAINT PAS_ID_NV |
31 | CHECK(LENGTH(PAS_ID) > 0), |
32 | CONSTRAINT PAS_NOM_NV |
33 | CHECK(LENGTH(PAS_NOMBRE) > 0) |
34 | )' |
35 | ); |
36 | } |
37 | |
38 | return self::$pdo; |
39 | } |
40 | } |
41 | |