Download the PHP package minnur/array-query without Composer
On this page you can find all versions of the php package minnur/array-query. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download minnur/array-query
More information about minnur/array-query
Files in minnur/array-query
Package array-query
Short Description Array Query
License MIT
Homepage https://github.com/minnur/array-query
Informations about the package array-query
Array Query
Array Query allows you to perform queries on multidimensional arrays.
Use Cases
This library is suitable for you if you need to perform some queries on:
- static php arrays
- in-memory stored arrays
- parsed json (or yaml) files
Basic Usage
To instantiate the QueryBuilder do the following:
Data consistency
QueryBuilder checks for your data consistency. If an inconsistency is detected a NotConsistentDataException
will be raised:
Quering, sorting and get results
You can perform queries on your array. You can concatenate criteria:
Avaliable criteria operators
=
(default operator, can be omitted)>
<
<=
>=
!=
ARRAY_MATCH
CONTAINS
(case insensitive)ENDS_WITH
EQUALS_DATE
GT_DATE
GTE_DATE
IN_ARRAY
IN_ARRAY_INVERSED
LT_DATE
LTE_DATE
STARTS_WITH
Avaliable sorting operators
ASC
(default operator, can be omitted)DESC
DATE_ASC
DATE_DESC
Joins
You can join arrays. Please consider this full example:
Limit and Offset
You can add criteria and specify limit and offset for your query results:
Working with dates
You can perform queries based on datetime fields. You can use DATE_ASC
or DATE_DESC
operator to sort results by date. You must specify date format if your format is not YYYY-mm-dd
:
Aliases
You can use aliases by using the as
keyword as a delimiter. Do the following:
Shuffled results
You can shuffle query results by using getShuffledResults
method:
More examples
Please refer to QueryBuilderTest for more examples.
Support
If you found an issue or had an idea please refer to this section.
Authors
- Mauro Cassani - github
License
This project is licensed under the MIT License - see the LICENSE.md file for details