<?php
define('DB_DRIVER', 'pgsql');
define('DB_HOST', 'aws-1-ap-southeast-2.pooler.supabase.com');
define('DB_PORT', '6543');
define('DB_NAME', 'postgres');
define('DB_USER', 'postgres.ysctoqmvvyshlkkfxsgq');
define('DB_PASS', 'qokc12eVuQSlYbew');

function db() {
  static $pdo;
  if (!$pdo) {
    $dsn = DB_DRIVER . ':host=' . DB_HOST . ';port=' . DB_PORT . ';dbname=' . DB_NAME;
    $pdo = new PDO($dsn, DB_USER, DB_PASS, [
      PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
      PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
      PDO::ATTR_EMULATE_PREPARES => false,
    ]);
  }
  return $pdo;
}