PHPackages                             dgvirtual/codeigniter4-firebird - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. dgvirtual/codeigniter4-firebird

ActiveLibrary[Database &amp; ORM](/categories/database)

dgvirtual/codeigniter4-firebird
===============================

PDO-based Firebird/InterBase database driver for CodeIgniter 4

v1.0.2(1mo ago)08↓100%MITPHPPHP ^8.1

Since Mar 18Pushed 1mo agoCompare

[ Source](https://github.com/dgvirtual/codeigniter4-firebird)[ Packagist](https://packagist.org/packages/dgvirtual/codeigniter4-firebird)[ Docs](https://github.com/dgvirtual/codeigniter4-firebird)[ RSS](/packages/dgvirtual-codeigniter4-firebird/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (2)Versions (4)Used By (0)

Firebird Database Driver for CodeIgniter 4
==========================================

[](#firebird-database-driver-for-codeigniter-4)

A PDO-based Firebird/InterBase database driver for CodeIgniter 4, initially based on [leirags/CI4-PDO-Firebird](https://github.com/leirags/CI4-PDO-Firebird).

Requirements
------------

[](#requirements)

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

Installation
------------

[](#installation)

```
composer require dgvirtual/codeigniter4-firebird
```

Then add a database group to `app/Config/Database.php` (see [Configuration](#configuration) below).

Configuration
-------------

[](#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
-----

[](#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
------------------

[](#supported-features)

### Connection

[](#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

[](#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

[](#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

[](#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

[](#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--identifier-handling)

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

Running Tests
-------------

[](#running-tests)

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

### 1. Install dependencies

[](#1-install-dependencies)

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

### 2. Start a Firebird server

[](#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)

[](#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 ``entries:

```

```

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

### 4. Run the tests

[](#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)
-----------------------------------------

[](#known-limitations-needs-checkingupdate)

AreaLimitation**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.

###  Health Score

40

—

FairBetter than 87% of packages

Maintenance96

Actively maintained with recent releases

Popularity7

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

3

Last Release

52d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c37acd333f5bf437ef9506328912e279f64fd3b87959b023a73ada7a8fdede4e?d=identicon)[dgvirtual](/maintainers/dgvirtual)

---

Tags

databasepdocodeigniter4firebirdinterbase

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/dgvirtual-codeigniter4-firebird/health.svg)

```
[![Health](https://phpackages.com/badges/dgvirtual-codeigniter4-firebird/health.svg)](https://phpackages.com/packages/dgvirtual-codeigniter4-firebird)
```

###  Alternatives

[doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.

9.7k578.4M5.6k](/packages/doctrine-dbal)[ifsnop/mysqldump-php

PHP version of mysqldump cli that comes with MySQL

1.3k5.5M68](/packages/ifsnop-mysqldump-php)[nette/database

💾 Nette Database: layer with a familiar PDO-like API but much more powerful. Building queries, advanced joins, drivers for MySQL, PostgreSQL, SQLite, MS SQL Server and Oracle.

5656.7M231](/packages/nette-database)[dibi/dibi

Dibi is Database Abstraction Library for PHP

5013.8M120](/packages/dibi-dibi)[aura/sqlquery

Object-oriented query builders for MySQL, Postgres, SQLite, and SQLServer; can be used with any database connection library.

4572.9M34](/packages/aura-sqlquery)[envms/fluentpdo

FluentPDO is a quick and light PHP library for rapid query building. It features a smart join builder, which automatically creates table joins.

925511.7k13](/packages/envms-fluentpdo)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
