diff --git a/lib/PostgresDb.php b/lib/PostgresDb.php new file mode 100644 index 0000000..94ee75e --- /dev/null +++ b/lib/PostgresDb.php @@ -0,0 +1,57 @@ +pdo = new PDO($dsn, $user, $password, [ + PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, + PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC + ]); + + } catch (PDOException $e) { + + die("Database connection failed: " . $e->getMessage()); + + } + } + + + public function query($sql, $params = []) + { + $stmt = $this->pdo->prepare($sql); + $stmt->execute($params); + + return $stmt; + } + + + public function fetchAll($sql, $params = []) + { + return $this->query($sql, $params)->fetchAll(); + } + + + public function fetch($sql, $params = []) + { + return $this->query($sql, $params)->fetch(); + } + + + public function lastInsertId() + { + return $this->pdo->lastInsertId(); + } +} \ No newline at end of file diff --git a/lib/functions.php b/lib/functions.php new file mode 100644 index 0000000..ed47710 --- /dev/null +++ b/lib/functions.php @@ -0,0 +1,37 @@ + 1 && strpos($extra, 'multiple') === FALSE) ? ' multiple="multiple"' : ''; + $form = ''; + return $form; + } +} +?> \ No newline at end of file