定制 artnum/structured-json-query 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

artnum/structured-json-query

最新稳定版本:v0.0.5

Composer 安装命令:

composer require artnum/structured-json-query

包简介

Convert a specific JSON structure to a SQL query or LDAP filter

README 文档

README

Convert a JSON object into an SQL where clause or into an LDAP filter.

JSON Query Object

AND, OR

Nesting of fields with AND and OR is possible with the keys #and and #or. This fields must take an object as a value. Nesting has no imposed limit on deepness.

Default operator and type

With no specific type and operator, it will default to equality operator and string type

{
    "#and": {
        "name": "John Doe",
        "city": "New York"
    }
}

Result :

  • SQL -> name = "John Doe" AND city = "New York"
  • LDAP -> (&(name=John Doe)(city=New York))

Sepcific type and operator

You can specify type and/or operator :

{
    "#and": {
        "name": {"operator": "~", "type": "str", "value": "Jo*"},
        "age": {"operator": ">=", "type": "int", "value": 21}
    }
}

Result:

  • SQL -> name LIKE "Jo%" AND age >= 21
  • LDAP -> (&(name=Jo*)(age>=21))

Nesting example

{
    "or": {
        "name": {"operator": "~", "value": "J*"},
        "#and": {
            "age": {"operator": "<", "type": "int", "value": 65},
            "age": {"operator": ">", "type": "int", "value": 18}
        }
    }
}

Result :

  • SQL -> (name LIKE "J*" OR (age < 65 AND age > 18))
  • LDAP -> (|(name=J*)(|(age<65)(age>18)))

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-03-29