fomadev/bridgesql 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

fomadev/bridgesql

最新稳定版本:2.0.1

Composer 安装命令:

composer require fomadev/bridgesql

包简介

Universal PDO library supporting 10 DBMS.

README 文档

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, data type management, and query debugging.

License: FPL PHP Version

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.
  • Logging & Debugging: Track execution time and view interpolated SQL queries for easier debugging.
  • 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:

  1. MySQL & MariaDB

  2. PostgreSQL

  3. SQLite (Local file or :memory:)

  4. Microsoft SQL Server (MSSQL)

  5. Oracle (OCI)

  6. IBM DB2

  7. Firebird

  8. Informix

  9. Sybase (SAP ASE)

Quick Use

Configuration

Create a configuration file (e.g., config/database.php):

return [
    'driver'   => 'mysql',
    'host'     => 'localhost',
    'dbname'   => 'my_database',
    'username' => 'root',
    'password' => '',
    'charset'  => 'utf8mb4'
];

Query Execution & Debugging

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]);

// Insert data with auto-typing
$db->execute("INSERT INTO users (name, active) VALUES (?, ?)", ["Molengo", true]);

// --- Debugging Features (New in v2.0.1) ---

// Get the last executed query with parameters injected
echo $db->getLastQuery(); 
// Output: INSERT INTO users (name, active) VALUES ('Molengo', 1)

// Get full session logs (SQL, duration, and timestamp)
$logs = $db->getDebugLog();
print_r($logs);

Transactions

$db->beginTransaction();

try {
    $db->execute("UPDATE accounts SET balance = balance - 100 WHERE id = 1");
    $db->execute("UPDATE accounts SET balance = balance + 100 WHERE id = 2");
    $db->commit();
} catch (Exception $e) {
    $db->rollBack();
    throw $e;
}

Contributing

Please see CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests.

License

This project is licensed under the FomaDev Public License (FPL).

  • Free for use as a dependency in personal and commercial projects.
  • Paid license required for redistribution, derivative libraries, or competing commercial services.

See the LICENSE file for the full text.

统计信息

  • 总下载量: 3
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: proprietary
  • 更新时间: 2025-11-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固