PHP Integrated query - Official site
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.
$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 is compatible with >= PHP 5.4
Add package to your composer.json:
{
"require": {
"timetoogo/pinq": "~2.1"
}
}