soluble / flexstore
FlexStore
0.13.1
2019-04-14 21:20 UTC
Requires
- php: ^7.1
- ext-intl: *
- soluble/dbwrapper: ^1.3 || ^2.0
- soluble/metadata: ^1.3
- soluble/spreadsheet: 0.*
- symfony/polyfill-iconv: ^1.3.0
- zendframework/zend-paginator: ^2.4.0 || ^3.0.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.14.2
- phpoffice/phpexcel: ^1.8
- phpstan/phpstan: ^0.11.3
- phpstan/phpstan-strict-rules: ^0.11
- phpunit/phpunit: ^6.0 || ^7.0
- soluble/php_excel_dev: ^0.1
- symfony/polyfill-mbstring: ^1.1.1
- zendframework/zend-cache: ^2.3 || ^3.0
- zendframework/zend-db: ^2.4.0 || ^3.0
- zendframework/zend-inputfilter: ^2.3 || ^3.0
- zendframework/zend-json: ^2.3 || ^3.0
- zendframework/zend-validator: ^2.3 || ^3.0
- zendframework/zend-view: ^2.8.2
Suggests
- soluble/dbwrapper: soluble-dbwrapper datasource support (universal database wrapper).
- zendframework/zend-db: zendframework db select datasource support
This package is auto-updated.
Last update: 2024-09-15 08:41:48 UTC
README
简介
特性
- 可扩展的数据源
- ColumnModel变更
- 渲染器和格式化程序
- 自定义写入器
需求
- PHP引擎5.6+, 7.0+
文档
安装
通过composer快速安装。
$ composer require soluble/flexstore
大多数现代框架都内置了Composer,但请确保包含以下文件
<?php // include the Composer autoloader require 'vendor/autoload.php';
快速开始
API
获取存储库
从zend-db选择获取存储库。
<?php use Soluble\FlexStore\Store; use Soluble\FlexStore\Source; use Zend\Db\Adapter\Adapter; use Zend\Db\Sql\Select; // 1. Database adapter $adapter = new Adapter([ 'driver' => 'mysqli', // or PDO_Mysql 'hostname' => $hostname, 'username' => $username, 'password' => $password, 'database' => $database, 'charset' => 'UTF-8' ]); // 2. Make a select $select = new Select(); $select->from('product') ->where(['flag_archive' => 0]); // 3. Create a datasource $sqlSource = new Source\Zend\SqlSource($adapter, $select); // 4. Get a Store $store = new Store($sqlSource);
在存储库中检索数据
<?php use Soluble\FlexStore\Store; use Soluble\FlexStore\Options; // 4. Get a Store $store = new Store($sqlSource); $options = new Options(); $options->setLimit(10); $data = $store->getData($options); foreach ($data as $idx => $row) { // The $row is an ArrayObject echo $idx . '-' . $row['column'] . PHP_EOL; }
获取ColumnModel
<?php use Soluble\FlexStore\Store; use Soluble\FlexStore\Options; // 4. Get a Store $store = new Store($sqlSource); $cm = $store->getColumnModel(); $columns = $cm->getColumns(); // Will look like [ ["col_1_name"] => (Soluble\FlexStore\Column\Column) ["col_2_name"] => (Soluble\FlexStore\Column\Column) ] // Getting information about a column $column = $cm->getColumn("col_1_name"); $properties = $column->getProperties(); $column->getName(); $column->getHeader(); $column->getType(); $column->getFormatter(); $column->getWidth(); $column->isEditable(); $column->isExcluded(); $column->isFilterable(); $column->isGroupable(); $column->isSortable();
API
存储库
Soluble\FlexStore\Store
选项
Soluble\FlexStore\Options
可用于修改数据检索过程。
结果集
Store::getData()
方法返回一个实现Resultset\ResultsetInterface
的结果集。此接口是可遍历的、可计数的,并实现了Iterator
接口(foreach...)
ColumnModel
ColumnModel允许更改列的检索或显示方式。
必须在调用Store::getData()
方法之前调用。
基本信息
排序列
更改检索列的顺序。
获取或设置排除项
被排除的列不会被Store::getData()
方法检索。
添加虚拟列
添加一个在底层源中不存在的列。此列的值通常由渲染器计算。
搜索列
您可以在ColumnModel中搜索匹配特定模式的列。
元数据
元数据目前是自动检索的(这可能会改变...)
在ColumnModel上搜索
您可以在ColumnModel中搜索匹配特定模式的列,并对结果应用操作。
使用关联的Search\Result
,您可以轻松地
在ColumnModel上搜索
您可以在ColumnModel中搜索匹配特定模式的列,并对结果应用操作。
支持的驱动程序
贡献
欢迎贡献,请参阅贡献指南