rherb / php-odata-query-builder
PHP OData 查询构建器
v1.0.1
2022-12-15 05:57 UTC
Requires
- php: ^7.0
Requires (Dev)
- phpunit/phpunit: ^8.5
This package is auto-updated.
Last update: 2024-09-15 09:36:24 UTC
README
此库用于流畅地构建 OData 查询字符串。在 Packagist 上查看。
安装库
您可以使用 Composer 安装 PHP 库。
composer require rherb/php-odata-query-builder
要创建构建器,请将服务 URL 和实体集传递给构造函数。
$builder = new ODataQueryBuilder('http://services.odata.org/V4/TripPinService/', 'People');
构建查询字符串
使用各种函数,然后调用 buildQuery() 函数来生成和返回查询字符串。
$builder->from('People')->top(10)->buildQuery(); $builder->from('People')->find('bobjoe')->buildQuery(); $builder->from('Books')->filter('Cost')->lessThan(20)->buildQuery(); $builder->from('People')->filter('LastName')->equals('Smith')->buildQuery(); $builder->from('People')->filter('LastName')->equals('Smith')->andFilter('FirstName')->equals('Joe')->buildQuery();
请查看测试用例以获取更复杂的示例。