dev-master
9999999-devA filtering api
MIT
The Requires
- php >=7.0
The Development Requires
v0.0.1
0.0.1.0A filtering api
MIT
The Requires
- php >=7.0
The Development Requires
A filtering api
A fluent interface for filtering data., (*1)
The (highly) recommended way to install Osmosis is by using Composer, (*2)
composer require lune/osmosis
The following operators are available:, (*3)
equals, (*4)
inArray, (*5)
greaterThan, (*6)
greaterThanOrEqual, (*7)
lessThan, (*8)
lessThanOrEqual, (*9)
not, (*10)
notInArray, (*11)
The following DataSources are bundled:, (*12)
Wraps an array and filters it, (*13)
$filter = new Lune\Osmosis\Filter() $filter ->equals('a', 1) ->greaterThan('b', 100); $array = [ ['a'=>1, 'b'=>20], ['a'=>1, 'b'=>120], ['a'=>3, 'b'=>120] ]; //Convert our array to a DataSourceInterface object $source = new Lune\Osmosis\DataSource\ArrayDataSource($array); //Apply the filter to our datasource $result = $filter->apply($source); print_r((array) $result); //[['a'=>1, 'b'=>'120']];
Creates partial sql:, (*14)
$filter = new Lune\Osmosis\Filter() $filter->equals('ID', 1); $source = new Lune\Osmosis\DataSource\SQLDataSource(); $result = $filter->apply($source); //Execution example $pdo = new \PDO(...); $statement = $pdo->prepare("SELECT * FROM `users` WHERE {$result}"); $statement->execute($result->getVariables())->fetchAll();
Please note Osmosis is by no means a complete query builder, nor does it aim to be one., (*15)
To add filters, simply use the methods provided:, (*16)
$filter = new Lune\Osmosis\Filter() $filter ->equals('a', 1) ->greaterThan('b', 100);
You can also use a callable as the constructor parameter:, (*17)
$filter = new Lune\Osmosis\Filter(function(FilterInterface $f){ $f->equals('a', 1)->greaterThan('b', 100); });
A filtering api
MIT
A filtering api
MIT