Download the PHP package exegeseit/doctrinequerysearch-helper without Composer
On this page you can find all versions of the php package exegeseit/doctrinequerysearch-helper. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download exegeseit/doctrinequerysearch-helper
More information about exegeseit/doctrinequerysearch-helper
Files in exegeseit/doctrinequerysearch-helper
Package doctrinequerysearch-helper
Short Description This package aims to facilitate the creation of dynamic WHERE clauses when using Doctrine\ORM\Querybuilder or Doctrine\DBAL\Querybuilder
License MIT
Informations about the package doctrinequerysearch-helper
DoctrineQuerySearchHelper
This package aims to facilitate the creation of dynamic WHERE clauses when using Doctrine\ORM\Querybuilder or Doctrine\DBAL\Querybuilder
It rely on:
- QueryClauseBuilder, a Querybuilder helper in charge of creating the final WHERE clause, based on an array of $search conditions
- SearchFilter, a complete set of static helpers to define the $search conditions array
Installation
DoctrineQuerySearchHelper require at least PHP 8.1
Run the following command to install it in your application:
How it works / Basic usage
The basic use of this package is to create a "fetchQb" method in your entity's repository. This method will receive our $search condition array as a parameter and return a fully defined Querybuilder instance (SELECT statement + WHERE statement).
Internally, an instance of QueryClauseBuilder is used to define allowed search keys and their mapping to properties of entities involved in defining the SELECT statement part of the returned QueryBuilder instance.
The following example shows how to achieve this.
The $search parameter, on the other hand, is an associative array where each line defines one of the conditions of the final WHERE clause in the form:
searchKey_filter => searchKey_value
The searchKey_filter key is generated using the appropriate SearchFilter helper as described later in the "SearchFilter Wizards" section
Usage
Take a look at the fetchMarketQb method which creates a QueryBuilder to fetch "Market" objects. In particular, see how the different "search keys" are declared, which will allow you to filter the results. It also defines an default ORDER BY clause
Now, we can use our repository method to get a filtered list of Market. It also defines an default ORDER BY clause
SearchFilter Wizards
SearchFilter also provide two Composition helper:
All versions of doctrinequerysearch-helper with dependencies
doctrine/orm Version ^2.9 | ^3.0
symfony/polyfill-ctype Version ^1.0
symfony/polyfill-mbstring Version ^1.0