mapbender/query-builder
Composer 安装命令:
composer require mapbender/query-builder
包简介
Mapbender query builder element
README 文档
README
The QueryBuilder is a Mapbender element. It is a query tool and enables the integration, display and editing of SQL queries and their result visualisation and export via the application interface.
Mapbender
See Official site | Live demo | News on Fosstodon
Installation
Use composer require mapbender/query-builder and register MapbenderQueryBuilderBundle with the Symfony application kernel.
Contributing
Please read official contibuting documentation
QueryBuilder Functionality
You can use the QueryBuilder element in the sidepane.
Depending on the settings, the QueryBuilder allows you to
- create, edit and delete queries
- execute queries
- output as Html
- Display in dialog
- Export to Excel
- Search
The respective authorizations for the query options can be assigned in the configuration of the element
Configuration
You need an administration table in your database where you store your sql definitions (see example below).
- Title: Title of the element.
- Configuration: YAML-Field to define the connection and settings for the administration table:
- connection: database connection name (as defined in
doctrine.yaml, default:default) - table: administration table name where the queries are stored (required)
- uniqueId: refer to the unique id of the table (default:
id) - titleFieldName: name to display for the SQL query. Appears later in the SQL query table as the title. (default:
name) - sqlFieldName: table column with the SQL query (default:
sql_definition) - orderByFieldName: table column for specifying the order in the SQL query table (default:
id) - connectionFieldName: table column with the database connection for the SQL query (default: the same connection as given in
connection) - filter: definition of a filter if not all queries should be visible as sql WHERE query, e.g.
active = 1(optional) - export_format:: file type for the file export:
xlsx(default),xlsorcsv
- connection: database connection name (as defined in
Example:
connection: geodata_db table: query_builder_data uniqueId: id titleFieldName: name sqlFieldName: sql_definition orderByFieldName: ordering connectionFieldName: connection_field_name filter: 'active is not null' export_format: xlsx
There are also some options that you can configure:
- Allow execute: If checked, users can execute the query to show the results in a popup (default:
true). - Allow search: If checked, users can filter the query list and popup results by a search string (default:
false). - Allow HTML export: If checked, users can view the data as a printable HTML page in a new window (default:
true) - Allow file export: If checked, users can download the query results as a spreadsheet file (xlsx, xls or csv depending on configuration; default:
true)
You can either modify the queries directly in the database, the query builder also supports manipulating the data directly in mapbender. Since allowing users to modify arbitrary SQL is a potential security threat, in addition to checking the respective checkboxes, users with edit rights also need to be granted a global permission (Security - Global Permissions - QueryBuilder).
In addition to the permissions, the databases that allow executing query builder queries need to be defined in the parameters.yaml file using the parameter querybuilder_allowed_connections, e.g.
parameters: querybuilder_allowed_connections: - default - geodata
The following configuration entries toggle the availability of editing functionality:
- Allow save: If checked, users with the permission QueryBuilder.edit can modify existing queries (default:
false). - Allow create: If checked, users with the permission QueryBuilder.create can add new queries (default:
false). - Allow remove: If checked, users with the permission QueryBuilder.remove can remove existing queries (default:
false).
Administration table to store the query definitions and metadata
This administration table can be created in an existing database using the following SQL command. This is just an example, you can choose the column names freely, just adjust the configuration accordingly.
CREATE TABLE public.query_builder_data (
id serial PRIMARY KEY,
name character varying,
sql_definition text,
active integer,
ordering integer,
connection_field_name character varying
);
The following demodata with SQL queries can be used for the exemplary use. The SQL commands for the creation of the queried tables can be found in the documentation for the digitizer element.
INSERT INTO public.query_builder_data (id, name, sql_definition, active, ordering, connection_field_name) VALUES (1, 'Report 1: Time and Date', 'Select now() as "Zeit", date(now()) as "Datum";', 1, 1, 'geodata_db');
INSERT INTO public.query_builder_data (id, name, sql_definition, active, ordering, connection_field_name) VALUES (3, 'Report 2: Mapbender applications', 'Select id, title, slug from mb_core_application;', 1, 4, 'default');
INSERT INTO public.query_builder_data (id, name, sql_definition, active, ordering, connection_field_name) VALUES (4, 'Report 3: Mapbender users', 'Select id, username from fom_user;', 1, 3, 'default');
INSERT INTO public.query_builder_data (id, name, sql_definition, active, ordering, connection_field_name) VALUES (2, 'Hello world', 'Select now() as "Zeit", date(now()) as "Datum", ''Hello world!'' as gruss;', 1, 2, 'default');
mapbender/query-builder 适用场景与选型建议
mapbender/query-builder 是一款 基于 JavaScript 开发的 Composer 扩展包,目前已累计 919 次下载、GitHub Stars 达 3, 最近一次更新时间为 2016 年 04 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「data」 「query builder」 「mapbender」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 mapbender/query-builder 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mapbender/query-builder 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 mapbender/query-builder 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Shoot aims to make providing data to your templates more manageable
Adds the EDTF data type to Wikibase
A simple library that allows transform any kind of data to native php data or whatever
Query filtering in your frontend
A Sphinx Query Builder extension for the Laravel Database package
Anax Database Active Record module for model classes.
统计信息
- 总下载量: 919
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 19
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-04-26