kennyyuen/shark-query-expression 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

kennyyuen/shark-query-expression

最新稳定版本:0.1.5

Composer 安装命令:

composer require kennyyuen/shark-query-expression

包简介

README 文档

README

The query-expression is a PHP library designed to convert a set of expression to query.

Installation

You can install the library via Composer:

composer require kennyyuen/shark-query-expression

Query Support

  • MySQL

Usage

To use the query-expression, include the autoload file generated by Composer:

<?php
require 'vendor/autoload.php';

use Shark\Extensions\QueryExpression\Evaluator;
use Shark\Extensions\QueryExpression\Parsers;

$evaluator = new Evaluator(Parsers::SQL);
$query = $evaluator->eval("*1*2*", "your_field_name");

// Output: ["your_field_name LIKE ?", ["%1%2%"]]

Examples

Example 1 - Multiple items with exact values

// 'some-value|some-other-value'
// 
// Or using whitespace (only work for exact value)
// 'some-value some-other-value'
//
// Note: it only supports alphanumeric, underscore and hyphen value

use Shark\Extensions\QueryExpression\Evaluator;
use Shark\Extensions\QueryExpression\Parsers;

$evaluator = new Evaluator(Parsers::SQL);
$query = $evaluator->eval("*1*2*", "your_field_name");

// Output: ["your_field_name LIKE ?", ["%1%2%"]]

Example 2 - Between two values

# Between 5 and 10
>=5&<=10

Example 3 - Like pattern

# Starting with 'ABC'
ABC*

Supported Syntax

Comparison operator can be combined with logic operator

OperatorTypeExampleDescription
<Comparison Operator<15Less than...( Not include ...)
<=Comparison Operator<=15Less than or equal to ... ( Include ... )
>Comparison Operator>15Greater than ( Not include ... )
>=Comparison Operator>=15Greater than or equal to ... ( Include .. )
<>Comparison Operator<>15Not equal to ...
| Wildcard Comparison Operator | bcLike ...
|Logic Operatorabc|cde... Or ...
&Logic Operatorabc&cde... And ...
whitespaceLogic Operatorabc cde... Or ...

Contributing

Contributions are welcome! Please submit a pull request or open an issue to discuss your ideas.

License

This project is licensed under the MIT License.

统计信息

  • 总下载量: 1
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2025-01-29