Browse Source

src: Add a sqlite database

master
Elis Hirwing 3 years ago
parent
commit
d6c3ec7508
Signed by: etu GPG Key ID: D57EFA625C9A925F
  1. 1
      .gitignore
  2. 21
      public/index.php

1
.gitignore

@ -1 +1,2 @@
sqlite.db
vendor/

21
public/index.php

@ -27,6 +27,27 @@ $container['logger'] = function (Slim\Container $c) {
return $logger;
};
$container['db'] = function (Slim\Container $c) {
$pdo = new PDO('sqlite:../sqlite.db');
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ);
$pdo->exec(
'DROP TABLE IF EXISTS inventory;'
);
$pdo->exec(
'CREATE TABLE inventory (
item_id INTEGER PRIMARY KEY,
item_name TEXT NOT NULL,
item_stock INTEGER NOT NULL
);'
);
return $pdo;
};
/**
* Set up controllers
*/

Loading…
Cancel
Save