一个简单的查询字符串解析器

v0.1.3 2015-07-21 15:49 UTC

This package is not auto-updated.

Last update: 2024-09-18 10:24:48 UTC


README

PHP查询字符串解析器

触摸与走示例

假设你有一个以下查询

q=age<19,gender=male&embeds=bags.offers&includes=age,gender&excludes=whatever&sort=%2bupdated_at,-count

这相当复杂!Quip使得解析此类查询变得异常简单

$query = 'q=age<19,gender=male&embeds=snags.offers&includes=age,gender&excludes=whatever&sort=%2bupdated_at,-count'

$quip = (new Quip($query))->parse();

$quip->getIncludes();
// ['age', 'gender']

$quip->getExcludes();
// ['whatever']

$quip->getSorts();
// Array of sort objects, with type (ascending/descending) and field to sort on 

$quip->getEmbeds();
// Array of EmbedChain objects, which house sorted arrays of parsed `x.y` strings

$quip->getExpressions();
// Returns expressions (left-hand-side, right-hand-side and operator) from the `q` parameter

这仍然是一个正在进行中的主要工作,但我希望它会很有用!