=== PostgreSQL PDO Connection Examples === Example 1: Singleton Pattern ---------------------------- Singleton connection works! Example 2: Helper Function (Recommended) ---------------------------------------- Connected to database: frcsdb as user: taf Example 3: Prepared Statements ------------------------------ Number of tables in public schema: 446 Example 4: Transaction Example ------------------------------ Transaction test value: 1 Transaction committed successfully Example 5: Error Handling ------------------------- Caught expected error: SQLSTATE[42P01]: Undefined table: 7 ERROR: relati... Error handling works correctly! Example 6: Schema Information ----------------------------- Sample tables in the database: - account_ai_feedback (owner: taf) - appeals (owner: taf) - applications (owner: taf) - appraisal_templates (owner: taf) - attendance (owner: taf) Example 7: Different Fetch Methods ---------------------------------- Database name (fetchColumn): frcsdb Single row (fetch): DB=frcsdb, User=taf Multiple rows (fetchAll): row1, row2 === Quick Usage Summary === 1. Simple query: $pdo = getDb(); $result = $pdo->query('SELECT ...'); 2. Prepared query: $stmt = $pdo->prepare('SELECT * FROM table WHERE id = ?'); $stmt->execute([$id]); 3. Insert/Update: $stmt = $pdo->prepare('INSERT INTO table VALUES (?, ?)'); $stmt->execute([$val1, $val2]); 4. Transaction: $pdo->beginTransaction(); /* operations */ $pdo->commit(); 5. Test connection: if (testDbConnection()) { /* proceed */ }