承接 dgvirtual/codeigniter4-firebird 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

dgvirtual/codeigniter4-firebird

Composer 安装命令:

composer require dgvirtual/codeigniter4-firebird

包简介

PDO-based Firebird/InterBase database driver for CodeIgniter 4

README 文档

README

A PDO-based Firebird/InterBase database driver for CodeIgniter 4, initially based on leirags/CI4-PDO-Firebird.

Requirements

  • PHP 8.1 or higher
  • ext-pdo with the pdo_firebird extension enabled
  • CodeIgniter 4.7 or higher

Installation

composer require dgvirtual/codeigniter4-firebird

Then add a database group to app/Config/Database.php (see Configuration below).

Configuration

// app/Config/Database.php

public array $firebird = [
    'DSN'      => 'firebird:dbname=192.168.1.10:/path/to/database.fdb;charset=UTF8;dialect=3',
    'hostname' => '',
    'port'     => '',           // default Firebird port: 3050
    'username' => 'DBUSERHERE',
    'password' => 'DbPasswordHere',
    'database' => '',
    'DBDriver' => 'Dgvirtual\CI4Firebird',
    'DBPrefix' => '',
    'pConnect' => false,
    'DBDebug'  => true,
    'charset'  => 'UTF8',
    'DBCollat' => '',
    'swapPre'  => '',
    'encrypt'  => false,
    'compress' => false,
    'strictOn' => false,
    'failover' => [],
];

Or:

    // app/Config/Database.php
    public $firebird = [
        'DSN'      => '',
        'hostname' => 'example.com',
        'port'     => '3050',
        'username' => 'DBUSERHERE',
        'password' => 'DbPasswordHere',
        'database' => 'databasename',
        'DBDriver' => 'Dgvirtual\CI4Firebird',
        'DBPrefix' => '',
        'pConnect' => false,
        'DBDebug'  => (ENVIRONMENT !== 'production'),
        'charset'  => 'UTF8',
        'swapPre'  => '',
        'failover' => [],
];

Note: DBDriver must be set to the namespace Dgvirtual\CI4Firebird.

Usage

// Connect explicitly (e.g. in a controller)
$db = \Config\Database::connect('firebird');

// In a model
class MyModel extends \CodeIgniter\Model
{
    protected $DBGroup = 'firebird';
    protected $table   = 'MY_TABLE';
    protected $primaryKey = 'ID';
    protected $returnType = 'object';
}

Supported features

Connection

  • Connects via PHP's PDO with the firebird: DSN prefix.
  • Supports both explicit config (hostname + port + database path) and a pre-built DSN string.
  • Error mode is set to PDO::ERRMODE_EXCEPTION — all driver errors throw exceptions.
  • reconnect() is implemented (closes and re-initialises the connection).

Querying

  • Full SELECT, INSERT, UPDATE, DELETE support through CodeIgniter's Query Builder.
  • Raw simpleQuery() / query() execution works normally.
  • Prepared statements are supported via PreparedQuery.
  • affectedRows() returns the correct row count via PDOStatement::rowCount().
  • A delete hack is applied automatically: bare DELETE FROM table statements are rewritten to DELETE FROM table WHERE 1=1 so that affectedRows() returns a meaningful value instead of 0.

Pagination

  • Uses Firebird's native SELECT FIRST n SKIP m … syntax instead of the standard LIMIT/OFFSET clause, which Firebird does not support.

Result set

  • getFieldCount(), getFieldNames(), and getFieldData() are implemented.
  • Result rows are buffered internally (full fetch into a PHP array) to work around PDO's lack of a native cursor-seek.
  • Return type can be configured to array or object as with any CI4 driver.

Schema introspection

  • listTables() — queries RDB$RELATIONS, filtering out system tables (RDB$*, SEC$*, MON$*). Table prefix filtering is supported.
  • listColumns() / _fieldData() — returns column names, Firebird native types, max length, and default values from RDB$RELATION_FIELDS / RDB$FIELDS.
  • _indexData() — returns index metadata from RDB$INDICES.
  • _foreignKeyData() — returns foreign key information.
  • getVersion() — returns the server version string via PDO::ATTR_SERVER_INFO.

String / identifier handling

  • String escaping uses Firebird-compatible single-quote doubling (''').
  • LIKE wildcard escaping is implemented in escapeLikeStringDirect().

Running Tests

The test suite requires a live Firebird server. Everything else is self-contained — no CI4 application project is needed.

1. Install dependencies

git clone https://github.com/dgvirtual/codeigniter4-firebird.git
cd codeigniter4-firebird
composer install

2. Start a Firebird server

The quickest way is Docker:

docker run -d --name firebird-test \
  -e ISC_PASSWORD=masterkey \
  -e FIREBIRD_DATABASE=test.fdb \
  -p 3050:3050 \
  jacobalberty/firebird:3.0

Note: Use the Firebird 3.x image. The php8.3-interbase / pdo_firebird package ships a Firebird 3 client library (LI-V6.3.x). Connecting it to a Firebird 4 server causes subtle mis-behaviour (most notably, PDO::rollBack() silently commits instead).

The test suite creates and drops its own tables (TEST_CATS, TEST_ITEMS), so any empty database works.

3. Configure credentials (if necessary)

The default credentials in phpunit.xml.dist match the Docker command above (SYSDBA / masterkey, database /firebird/data/test.fdb on localhost:3050).

If your server uses different credentials or a different path, copy phpunit.xml.dist to phpunit.xml (which is git-ignored) and adjust the <env> entries:

<env name="FIREBIRD_DSN"      value="firebird:dbname=myhost:/data/custom.fdb;charset=UTF8;dialect=3"/>
<env name="FIREBIRD_USER"     value="MYUSER"/>
<env name="FIREBIRD_PASSWORD" value="secret"/>

Setting FIREBIRD_DSN takes precedence over the individual FIREBIRD_HOST, FIREBIRD_PORT, and FIREBIRD_DATABASE variables.

4. Run the tests

vendor/bin/phpunit

If the firebird_test connection cannot be established (server unavailable, wrong credentials, missing pdo_firebird extension), every test is automatically skipped rather than failing — so the suite is safe to run in CI environments that do not have Firebird available.

Known limitations (Needs checking/update)

Area Limitation
Identifier quoting escapeChar is an empty string — column and table names are not quoted automatically. Identifiers that conflict with reserved words must be quoted manually in raw SQL.
Persistent connections The pConnect config option is passed through but Firebird's PDO driver does not reliably support persistent connections. Treat pConnect = FALSE as the safe default.
setDatabase() Always returns false. Switching to a different database after the connection is established is not possible.
PDO::ATTR_AUTOCOMMIT Cannot be set — the PDO Firebird driver throws an error. Auto-commit behaviour follows PDO Firebird's default.
Forge — CREATE DATABASE createDatabaseStr and createDatabaseIfStr are empty strings. Creating or dropping databases through CI4's Forge class is not supported.
Forge — column types The UNSIGNED list and table-option handling are copied from the MySQL driver and are not valid Firebird SQL. Using Forge to create or alter tables may produce incorrect DDL.
Forge — column types (DDL) UNSIGNED modifiers and MySQL-style table options are not valid Firebird SQL. Relying on Forge for schema management may produce incorrect DDL.
Utils — listDatabases Uses MySQL's SHOW DATABASES statement, which does not exist in Firebird. Calling $db->listDatabases() will throw an error.
Utils — _backup() Always throws DatabaseException: Unsupported feature. Database backup through CI4's Utils is not available.
INSERT IGNORE / UPDATE IGNORE supportedIgnoreStatements is empty — the Query Builder's ignore() modifier has no effect and will not produce valid SQL.
Memory usage All result rows are fetched into a PHP array at once (PDOStatement::fetchAll). Avoid using this driver for queries that return very large result sets.
Transactions — rollback The pdo_firebird PHP extension calls isc_commit_retaining() after every DML statement, which silently commits each row while keeping the transaction handle open. As a result, PDO::rollBack() (and CI4's transRollback()) cannot undo already-committed rows. commit() / transComplete() work correctly. This is a known limitation of the pdo_firebird extension.

dgvirtual/codeigniter4-firebird 适用场景与选型建议

dgvirtual/codeigniter4-firebird 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 22 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 03 月 18 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「database」 「pdo」 「firebird」 「interbase」 「codeigniter4」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 dgvirtual/codeigniter4-firebird 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 dgvirtual/codeigniter4-firebird 我们能提供哪些服务?
定制开发 / 二次开发

基于 dgvirtual/codeigniter4-firebird 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-18