ca90aa0cae5a243fc7ede5c415b2460b816a832a
[ga4php.git] / example / provisioning / dbfunctions.php
1 <?php
2
3 function getDatabase() {
4         $dbobject = false;
5         if(file_exists("/tmp/gadata.sqlite")) {
6                 try {
7                         $dbobject = new PDO("sqlite:/tmp/gadata.sqlite");
8                 } catch(PDOException $exep) {
9                         error_log("execpt on db open");
10                 }
11         } else {
12                 try {
13                         $dbobject = new PDO("sqlite:/tmp/gadata.sqlite");
14                 } catch(PDOException $exep) {
15                         error_log("execpt on db open");
16                 }
17                 $sql = 'CREATE TABLE "users" ("users_id" INTEGER PRIMARY KEY AUTOINCREMENT,"users_username" TEXT,"users_fullname" TEXT,"users_password" TEXT, "users_tokendata" TEXT);';
18                 $dbobject->query($sql);
19         }
20         
21         return $dbobject;
22 }
23
24 function closeDatabase($db) {
25         // doesnt do anything yet
26 }
27 ?>