Download the PHP package nmarniesse/pomm-filter without Composer

On this page you can find all versions of the php package nmarniesse/pomm-filter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package pomm-filter

Simple filter implementation for Pomm Project

Asking a collection of resources is often given with filter needs. But it's not always obvious to handle filters and build the query accordingly: multiple filters on different tables, multiple values for a filter, null values, dates, ...

This library provides a simple implementation to build query's condition from an array of filters.

Requirements and installation

Usage

The library helps to create an instance of PommProject\Foundation\Where that you could use in every pomm query (see here for further explanation).

To explain what we can do with this library, we can take a practical case: we want to filter on active products with color 'blue' or 'yellow', in category 'accessory', with price between 50 and 100, and which have one tag.

The filter array representation is:

With an HTTP query similar to ?filter[is_active]=1&filter[color][]=blue&filter[color][]=yellow&filter[category]=accessory&filter[price_from]=50&filter[price_from]=50&filter[price_to]=100&filter[tag]=_not_null_ you can have he same array in php with $array_filters = $_GET['filter'];.

You have your array filters, now let build the query:

Important note

Even if the generated Where condition protects the query against SQL injection, please note you must clean and validate the data coming from users, according to your business rules.

Documentation

FilterCollection

By default the FilterCollection does not contain any filter.

The method getWhere($filters) convert any associative array into Where instance When you do a getWhere(['key1' => 'val1']), it assumes that the key1 field exists in your query and build a simple condition query key1 = $* with parameter 'val1'.

If you want to specify a table alias in the condition query, or not use the = operator, you have to add the filter manually using the addFilter method.

Examples:

Filter types

This library provides several filter types to help you to create your own filter collection.

BasicFilter

As its name indicates, this class is useful to create simple filter.
However you can specify the operator you want to use (default is =) in order to customize the behavior of your filter.

DateTimeFilter

This filter allow you to use date values.

BooleanFilter

This filter is used to handle boolean fields.

HstoreFilter

This filter is used to handle hstore fields.

Given we have a hstore field full_address which contains keys like street, city, postal code, country, etc...

LtreeFilter

This filter is used to handle ltree fields. As ltree is commonly used to handle tree views, you can filter on a value and all its descendants using this filter. If you don't want to filter on the descendants the BasicFilter is enough.

RangeFilter

This filter is used to handle range fields. The value could be a single value or a range of values identified by a NMarniesse\PommFilter\ValueType\RangeValue object. In both cases, the filter tests the value is included into the range field.

Dev

Run unit tests


All versions of pomm-filter with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.4
psr/log Version ~1.0
pomm-project/foundation Version ~2.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package nmarniesse/pomm-filter contains the following files

Loading the files please wait ....