1. Go to this page and download the library: Download lune/osmosis library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
lune / osmosis example snippets
$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']];
$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();
$filter = new Lune\Osmosis\Filter()
$filter
->equals('a', 1)
->greaterThan('b', 100);
$filter = new Lune\Osmosis\Filter(function(FilterInterface $f){
$f->equals('a', 1)->greaterThan('b', 100);
});
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.