|
PostgreSQLDBC
A PHP library for managing PostgreSQL database connections with prepared statements.
|
PostgreSQLDBC is a lightweight PHP abstract base class that simplifies working with PostgreSQL using prepared statements. The class focuses on secure query execution, statement configuration and reuse, basic transaction support, and lightweight performance monitoring.
Highlights:
Files:
PostgreSQLDatabase to provide application-specific methods and manage configuration.Below is a minimal pattern showing how to extend the class and register prepared statements for reuse.
Configure($server, $user, $pass, $db) — Set connection parameters.Connect() / Disconnect() — Manage the database connection.ConfigureSTMT($name, $query) — Register a named prepared statement.ExecuteSTMT($name, ...$params) — Execute a named statement and return results or affected rows.StartTransaction(), EndTransaction($commit = true) — Transaction control helpers.EscapeString(), EscapeByteA(), UnEscapeByteA() — Utility escaping helpers.GetExecutedSTMTStatistics() / GetTimeSpent() — Basic performance statistics.For full reference, see the source implementation at lib/PostgreSQLDatabase.php.
ConfigureSTMT() and execute them with ExecuteSTMT().{a,b,c}).IsConnected() before running raw queries if connecting lazily.trigger_error() for fatal problems; wrap calls appropriately in applications where you need custom error handling.This project is published under the GNU General Public License v3.0 — see [LICENSE](LICENSE) for details.
Contributions, bug reports and pull requests are welcome. Please open issues or PRs on the upstream repository.
Developed by David Carlos Manuelda