codeies/json-query
最新稳定版本:v1.0.0
Composer 安装命令:
composer require codeies/json-query
包简介
PHP class for performing MySQL-like queries on JSON data.
README 文档
README
JsonQuery is a PHP class that allows you to perform operations similar to MySQL queries on JSON data, including searching, sorting, and pagination.
Installation
You can install JsonQuery via Composer by adding it as a dependency to your composer.json file:
composer require codeies/json-query
Usage
require_once 'vendor/autoload.php'; use Codeies\JsonQuery\JsonQuery; // Create a new instance of JsonQuery $jsonQuery = new JsonQuery('path/to/your/data.json'); // Find method $results = $jsonQuery->find('searchValue') ->sort('category', 'desc') ->paginate($page, $perPage) ->getData();
Methods
find($value) Searches for the specified value within the JSON data. sort($key, $order = 'asc') Sorts the filtered data by the specified key and order. paginate($page, $perPage) Paginates the filtered data based on the specified page number and items per page. getData() Returns the filtered and paginated data.
[
{"id": 1, "name": "Product 1", "category": "Category A", "price": 10.99},
{"id": 2, "name": "Product 2", "category": "Category B", "price": 20.99},
...
]
License
This project is licensed under the MIT License - see the LICENSE file for details.
Make sure to replace 'path/to/your/data.json' with the actual path to your JSON data file and update any placeholders with your actual project details.
This README.md file provides a brief overview of your package, instructions on how to install it using Composer, a usage example, details about the methods available, an example data format, and information about the license.
// Output results
print_r($results);
统计信息
- 总下载量: 7
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-03-27