我想知道是否有一个库实现类似SQL的接口来访问数组中的数据,例如是否有查询语言来过滤数组?
输入:
[
['name' => 'Tom', 'age' => 27, 'location' => ['country' => 'GB']],
['name' => 'Jerry', 'age' => 16, 'location' => ['country' => 'LT']],
['name' => 'Stuart', 'age' => 26, 'location' => ['country' => 'GB']]
]
虚构查询:
SELECT name, location.country FROM {input} WHERE age > 18 ORDER BY age DESC
将产生的变化:
[
['name' => 'Tom', 'location.country' => 'GB'],
['name' => 'Tom', 'location.country' => 'GB']
]
注意,我完全知道array_filter
和都实现,我可以当场放在一起。我正在寻找像接口一样的查询来访问数据。
似乎每一个linq库已经停产。我想知道是否因为其他原因没有用。我在“linq”名下找到的最新实现是https://github.com/Athari/YaLinqo。另一个是在我的答案中提到的ArrayQuery。 – Gajus