该包已弃用且不再维护。未建议替代包。

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

3.5.0 2020-11-15 10:05 UTC

This package is auto-updated.

Last update: 2023-01-03 16:24:55 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