giorrrgio / Pinq

PHP Integrated query, a real Linq library for PHP

Home Page:http://timetoogo.github.io/Pinq/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PHP Integrated query - Official site

Build status Code quality Coverage Status Stable Release License

What is Pinq?

Based off the .NET's Linq (Language integrated query), Pinq unifies querying across arrays/iterators and external data sources, in a single readable and concise fluent API.

An example

$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'],
            ]; 
        });

More examples

Installation

Pinq is compatible with >= PHP 5.4

Add package to your composer.json:

{
    "require": {
        "timetoogo/pinq": "~2.1"
    }
}

About

PHP Integrated query, a real Linq library for PHP

http://timetoogo.github.io/Pinq/