srun/yii2-kingbase
Composer 安装命令:
composer require srun/yii2-kingbase
包简介
Yii2 KingbaseES PostgreSQL-mode schema compatibility layer for SRun projects.
README 文档
README
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
composer require srun/yii2-kingbase:^1.0
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
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
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
After enabling this package in a Yii2 project:
getTableSchema('migration')should work.- ActiveRecord insert operations with serial primary keys should work.
yii migrate --interactive=0should 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
- PHP 7.4 or newer
- Yii2 2.x
pdo_pgsqlpdo
License
MIT
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-06-16