warrantgroup/doctrine-query-builder
Composer 安装命令:
composer require warrantgroup/doctrine-query-builder
包简介
An elegant lightweight library to dynamically build doctrine queries from structured data. Perfect for an API to interpret how data should be represented without any additional mapping.
README 文档
README
An elegant lightweight library to dynamically build doctrine queries from structured data. Perfect for an API to interpret how data should be represented without any additional mapping.
Supports unlimited nested AND/OR groups, most of the common SQL operators, joins, order by, distinct etc
Requirements:
- PHP >= 5.6
- Symfony HTTP Foundation > 3.2
- Doctrine ORM > 2.5
Installation:
With Composer:
{
"require": {
"warrantgroup/doctrine-query-builder": "dev-master"
}
}
Usage:
use \Warrant\Doctrine\QueryBuilder\QueryBuilder; $repo = $this->getDoctrine()->getManager()->getRepository('AcmeMainBundle:Person'); $qb = new QueryBuilder(); $results = $qb->build($repo, $data)->getQuery()->getResult(); return new JsonResponse($results);
Example data:
{
"alias": "p",
"select": ["p.id"],
"where": {
"$or": {
"p.city": {
"$same": "c.city"
},
"p.zipCode": {
"$same": "c.zipCode"
},
"p.street": {
"$same": "c.street"
},
},
"c.city": {
"$in": [
"New York",
"London"
]
},
"c.employees": { "$equals": 1 },
"l.code": 49,
"p.country": "$not_null",
"p.phone": "$is_null",
"c.assets": { "$gte": 1000 },
"c.turnover": { "$lt": 10000 },
"t.code": {
"$in": [1, 2, 3]
},
"r.title": {
"$not_in": ":titles"
}
},
"distinct": true,
"params": {
"titles": ["CFO", "CMO"]
},
"orderBy": {
"p.name": "asc"
},
"join": {
"p.roles": "r",
"r.company": "c",
"c.trades": {
"alias": "t",
"type": "left"
}
}
}
统计信息
- 总下载量: 10
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-01-17