hkvstore / pinq
PHP 集成查询 - PHP 的真实 LINQ 库
v3.5.1
2023-01-07 14:21 UTC
Requires
- php: >=7.4.0
- nikic/php-parser: ~4.10
Requires (Dev)
- doctrine/cache: 1.5.*
- phpunit/phpunit: ^9.0
- satooshi/php-coveralls: 1.0.*
This package is auto-updated.
Last update: 2024-09-07 17:41:12 UTC
README
什么是 PINQ?
基于 .NET 的 LINQ (语言集成查询),PINQ 统一了在 数组/迭代器 和 外部数据源 上的查询,在一个可读性和简洁性都很好的 流畅 API 中。
示例
$youngPeopleDetails = $people ->where(function ($row) { return $row['age'] <= 50; }) ->orderByAscending(function ($row) { return $row['firstName']; }) ->thenByAscending(function ($row) { return $row['lastName']; }) ->take(50) ->indexBy(function ($row) { return $row['phoneNumber']; }) ->select(function ($row) { return [ 'fullName' => $row['firstName'] . ' ' . $row['lastName'], 'address' => $row['address'], 'dateOfBirth' => $row['dateOfBirth'], ]; });
安装
PINQ 与 >= PHP 7.3 兼容
通过 composer 安装此包
composer require timetoogo/pinq