PHPackages                             srun/yii2-kingbase - 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. srun/yii2-kingbase

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

srun/yii2-kingbase
==================

Yii2 KingbaseES PostgreSQL-mode schema compatibility layer for SRun projects.

v1.0.0(1mo ago)03↓50%MITPHPPHP &gt;=7.4

Since Jun 16Pushed 1mo agoCompare

[ Source](https://github.com/srunsoft/kingbase)[ Packagist](https://packagist.org/packages/srun/yii2-kingbase)[ Docs](https://github.com/srunsoft/kingbase)[ RSS](/packages/srun-yii2-kingbase/feed)WikiDiscussions main Synced 2w ago

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

srun/yii2-kingbase
==================

[](#srunyii2-kingbase)

Yii2 KingbaseES PostgreSQL-mode schema compatibility layer.

This package provides a Yii2 database connection class for KingbaseES deployments that use the PostgreSQL-compatible PDO driver. It replaces Yii2's default PostgreSQL schema metadata query that calls `pg_get_serial_sequence(...)`, which is not compatible with some KingbaseES environments.

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

[](#installation)

```
composer require srun/yii2-kingbase:^1.0
```

Usage
-----

[](#usage)

Use the package connection class for Kingbase database components:

```
'components' => [
    'db' => [
        'class' => \srun\yii2\kingbase\Connection::class,
        'dsn' => 'pgsql:host=127.0.0.1;port=54321;dbname=srun4k',
        'username' => 'system',
        'password' => 'secret',
        'charset' => 'utf8',
    ],
],
```

The connection class extends `yii\db\Connection` and maps the `pgsql` driver to `\srun\yii2\kingbase\Schema\KingbaseSchema`.

If you need to keep using `yii\db\Connection`, you can configure the schema map explicitly:

```
'components' => [
    'db' => [
        'class' => \yii\db\Connection::class,
        'dsn' => 'pgsql:host=127.0.0.1;port=54321;dbname=srun4k',
        'username' => 'system',
        'password' => 'secret',
        'charset' => 'utf8',
        'schemaMap' => [
            'pgsql' => [
                'class' => \srun\yii2\kingbase\Schema\KingbaseSchema::class,
            ],
        ],
    ],
],
```

Why This Exists
---------------

[](#why-this-exists)

Yii2's PostgreSQL schema metadata query normally includes:

```
pg_get_serial_sequence(quote_ident(d.nspname) || '.' || quote_ident(c.relname), a.attname) AS sequence_name
```

In validated KingbaseES PDO pgsql environments, that query can fail during schema inspection. This package replaces the expression with:

```
NULL::varchar AS sequence_name
```

Yii2 can still infer autoincrement behavior from `column_default` when it contains `nextval(...)`, so standard ActiveRecord insert flows remain usable.

Scope
-----

[](#scope)

This package only solves framework-level schema metadata compatibility.

It does not include:

- business table migrations
- data cleanup SQL
- service script fixes
- authentication mode fixes
- ClickHouse, Redis, or portal integration fixes

Verification Checklist
----------------------

[](#verification-checklist)

After enabling this package in a Yii2 project:

- `getTableSchema('migration')` should work.
- ActiveRecord insert operations with serial primary keys should work.
- `yii migrate --interactive=0` should run without the previous metadata error.
- Schema cache can remain enabled after clearing old cache entries.

If the project previously cached broken schema metadata, clear runtime cache:

```
find runtime/cache -type f -delete
```

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

[](#requirements)

- PHP 7.4 or newer
- Yii2 2.x
- `pdo_pgsql`
- `pdo`

License
-------

[](#license)

MIT

###  Health Score

34

—

LowBetter than 74% of packages

Maintenance90

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity33

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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

Unknown

Total

1

Last Release

48d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/32881584b4218be963ef7863b7b35de612c2c6e934ef945091fbf18f6c06e51e?d=identicon)[liwenyu](/maintainers/liwenyu)

---

Top Contributors

[![dot-xiaoyuan](https://avatars.githubusercontent.com/u/53287231?v=4)](https://github.com/dot-xiaoyuan "dot-xiaoyuan (1 commits)")

---

Tags

postgresqlpgsqlyii2kingbasekingbasees

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/srun-yii2-kingbase/health.svg)

```
[![Health](https://phpackages.com/badges/srun-yii2-kingbase/health.svg)](https://phpackages.com/packages/srun-yii2-kingbase)
```

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.7M3.3k](/packages/craftcms-cms)[tigrov/yii2-pgsql

Improved PostgreSQL schemas for Yii2

3471.6k](/packages/tigrov-yii2-pgsql)[skeeks/cms

SkeekS CMS — control panel and tools based on php framework Yii2

13725.8k63](/packages/skeeks-cms)[delight-im/db

Safe and convenient SQL database access in a driver-agnostic way

47181.6k7](/packages/delight-im-db)[nanson/yii2-postgis

Yii2-extension to work with postgis data

1954.2k](/packages/nanson-yii2-postgis)

PHPackages © 2026

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