PHPackages                             braincrafted/arrayquery - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. braincrafted/arrayquery

ActiveLibrary

braincrafted/arrayquery
=======================

ArrayQuery is a library to query arrays.

v0.1(12y ago)10458MITPHP

Since Dec 4Pushed 11y ago2 watchersCompare

[ Source](https://github.com/braincrafted/arrayquery)[ Packagist](https://packagist.org/packages/braincrafted/arrayquery)[ RSS](/packages/braincrafted-arrayquery/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (3)Used By (0)

ArrayQuery
==========

[](#arrayquery)

ArrayQuery is a library to query arrays.

```
// Select the name of all of Ned's children older than 10.
$query = $qb->create()
    ->select('name')
    ->from([
        [ 'name' => 'Robb',   'age' => 15 ],
        [ 'name' => 'Sansa',  'age' => 11 ],
        [ 'name' => 'Arya',   'age' => 9 ],
        [ 'name' => 'Bran',   'age' => 7 ],
        [ 'name' => 'Rickon', 'age' => 3 ]
    ])
    ->where('age', 10, '>');
$result = $query->findAll();
```

[![Build Status](https://camo.githubusercontent.com/c0f06bf0187d1f3559ec2d86128351666bfd8e1b1d82134db91ca268af3dae18/68747470733a2f2f7472617669732d63692e6f72672f627261696e637261667465642f617272617971756572792e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/braincrafted/arrayquery)[![Scrutinizer Quality Score](https://camo.githubusercontent.com/a122b0f22528735fc80d571d625e757ffd3539c2a1c73e41407da46edbb710b6/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f627261696e637261667465642f617272617971756572792f6261646765732f7175616c6974792d73636f72652e706e673f733d38333464643761616665366665316538616138333030623433616130616535393235343839373338)](https://scrutinizer-ci.com/g/braincrafted/arrayquery/)[![Code Coverage](https://camo.githubusercontent.com/b0471c3ec9c8f3c970b2c3453a1f07aca5bd8ee725df44efec1897459db6d3c9/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f627261696e637261667465642f617272617971756572792f6261646765732f636f7665726167652e706e673f733d31633935663636613531336664613234663966383933323634616262326134333061376362613564)](https://scrutinizer-ci.com/g/braincrafted/arrayquery/)

Motivation
----------

[](#motivation)

Data is often stored in arrays of arrays (for example, after reading it from CSV) and some items (or rows) have to be picked out before the data can be further processed or stored in a database. Writing such code is not very hard, but it often gets messy. Loops within loops, multiple if or switch statement, temporary variables and so on. ArrayQuery provided a clean and testable interface (inspired by query builders from ORMs) for these "array queries."

Installation
------------

[](#installation)

ArrayQuery can be installed using Composer:

```
{
    "require": {
        "braincrafted/arrayquery": "dev-master"
    }
}
```

Usage
-----

[](#usage)

The `ArrayQuery` object has to be initialized with a `SelectEvaluation` and a `WhereEvaluation` object. Filters can be added to `SelectEvaluation` and filters and operators can be added to `WhereEvaluation`.

```
