hkvstore/pinq

PHP 集成查询 - PHP 的真实 LINQ 库

v3.5.1 2023-01-07 14:21 UTC

This package is auto-updated.

Last update: 2024-09-07 17:41:12 UTC


README

Build status Code quality Coverage Status Stable Release License

什么是 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