定制 srun/yii2-kingbase 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

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=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

  • PHP 7.4 or newer
  • Yii2 2.x
  • pdo_pgsql
  • pdo

License

MIT

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固