webman/admin 配置Pgsql

Achun

先在前台测试连接数据库,查询数据成功后再进行操作,记得先添加php扩展
(pgsql不是管理员账号一些操作会没有权限 username: postgres)
截图

在插件新增pgsql配置

截图


截图

copy Crud 重写为 Pgsql

截图

重写Pgsql selectInput方法

截图

$allow_column = Db::connection('plugin.admin.pgsql')
            ->select("SELECT column_name FROM information_schema.columns WHERE table_schema = 'public' AND table_name = '$table'");

        if (!$allow_column) {
            throw new BusinessException('表不存在');
        }
        $columns = array_column($allow_column, 'column_name', 'Field');
        $allow_column = array_flip($columns);
        if (!in_array($field, $columns)) {
            $field = null;
        }

重写Pgsql inputFilter方法

截图

$allow_column = Db::connection('plugin.admin.pgsql')
            ->select("SELECT column_name FROM information_schema.columns WHERE table_schema = 'public' AND table_name = '$table'");
        if (!$allow_column) {
            throw new BusinessException('表不存在', 2);
        }
        $columns = array_column($allow_column, 'column_name', 'Field');
        $columns = array_flip($columns);

最后修改模型连接配置

截图


目前增删改查操作都正常

截图

278 0 2
0个评论

Achun

340
积分
0
获赞数
0
粉丝数
2023-12-04 加入
×
🔝