fomadev / bridgesql
Universal PDO library supporting 10 DBMS.
2.0.0
2026-04-21 20:56 UTC
Requires
- php: >=8.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- phpunit/phpunit: ^10.0
This package is auto-updated.
Last update: 2026-04-21 21:02:29 UTC
README
BridgeSQL is a lightweight, universal PHP library designed to simplify the use of PDO. It acts as a robust bridge between your code and 10 different database management systems (DBMS), automating connection configuration and data type management.
Features
- Multi-DBMS Support: A single interface for 10 SQL engines (MySQL, PostgreSQL, SQLite, Oracle, SQL Server, etc.).
- Auto-Typing: Automatic detection of PDO types (Integer, Boolean, String, Null) via PHP 8
match. - Parameter Flexibility: Supports named (
:id) and indexed (?) parameters. - Security: Systematic use of prepared statements with emulation disabled for maximum security.
- Lightweight: No external dependencies required for basic operation.
Installation
Use Composer to install the library:
composer require fomadev/bridgesql
Supported DBMS
BridgeSQL facilitates connection to the following systems :
-
MySQL
-
MariaDB
-
PostgreSQL
-
SQLite (Local file)
-
Microsoft SQL Server
-
Oracle (OCI)
-
IBM DB2
-
Firebird
-
Informix
-
Sybase (SAP ASE)
Quick Use
Configuration
Create a configuration file (e.g., config/database.php):
return [ 'driver' => 'mysql', 'host' => 'localhost', 'dbname' => 'ma_base', 'username' => 'root', 'password' => '', 'charset' => 'utf8mb4' ];
Query execution
require 'vendor/autoload.php'; use BridgeSQL\BridgeSQL; $config = require 'config/database.php'; $db = new BridgeSQL($config); // Retrieve a single line $user = $db->fetch("SELECT * FROM users WHERE id = :id", ['id' => 1]); // Retrieve all the lines $users = $db->fetchAll("SELECT * FROM users WHERE status = ?", ["active"]); // Insert data $db->execute("INSERT INTO users (name, email) VALUES (?, ?)", ["Molengo", "fordi@fomadev.com"]); $lastId = $db->lastInsertId();