+
Skip to content

A simple PHP library that helps you easily filter and process data across different sources with reusable criteria

License

Notifications You must be signed in to change notification settings

imponeer/criteria

Repository files navigation

License GitHub release PHP Packagist

Criteria

A small PHP library to generate SQL WHERE, ORDER BY, and GROUP BY query parts. Inspired by Xoops CMS classes (CriteriaElement, Criteria, and CriteriaCompo), but fully rewritten and released under a more permissive open-source license.

Installation

The recommended way to install this package is via Composer:

composer require imponeer/criteria

Alternatively, you can manually include the files from the src/ directory.

Usage

Here is a basic example of how to use the Criteria library:

use Imponeer\Database\Criteria\CriteriaItem;
use Imponeer\Database\Criteria\CriteriaCompo;

$criteria = new CriteriaCompo();
$criteria->add(new CriteriaItem('status', 'active'));
$criteria->add(new CriteriaItem('age', 18, '>='));

// Generate SQL WHERE clause
$where = $criteria->render();
// $where will be: "(`status` = 'active' AND `age` >= 18)"

API Documentation

Full API documentation is available in the repository wiki. Documentation is automatically updated with every release.

Development

For development, use the following Composer commands:

  • Run tests:
    composer test
  • Run static analysis:
    composer phpstan
  • Run code style checks:
    composer phpcs

How to contribute?

If you want to add functionality or fix bugs, fork the repository, make your changes, and create a pull request.

If you find any bugs or have questions, please use the issues tab to report them or ask questions.

About

A simple PHP library that helps you easily filter and process data across different sources with reusable criteria

Topics

Resources

License

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •  

Languages

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载