Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/293.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Apigility rest服务-如何使用db connected按非唯一列进行筛选_Php_Rest_Zend Framework2_Laminas Api Tools - Fatal编程技术网

Php Apigility rest服务-如何使用db connected按非唯一列进行筛选

Php Apigility rest服务-如何使用db connected按非唯一列进行筛选,php,rest,zend-framework2,laminas-api-tools,Php,Rest,Zend Framework2,Laminas Api Tools,我有一个数据库连接的rest服务,到目前为止,我只设法从数据库或通过其ID获取完整的集合 我找不到合适的指南来解释如何使用GETurl参数按其他字段进行筛选,以及如何选择例如“LIKE”或LIKE%%”或其他运算符。这是我使用CodeConnected Services.YMMV的经验 检索URL参数-控制器/资源类。 您的控制器需要从$this->getEvent() 其次,只有module.config.php上批准的参数才能通过Apigility.Notice Collection Que

我有一个数据库连接的
rest
服务,到目前为止,我只设法从
数据库
或通过其
ID
获取完整的集合


我找不到合适的指南来解释如何使用
GET
url参数按其他字段进行筛选,以及如何选择例如“LIKE”或LIKE%%”或其他运算符。这是我使用CodeConnected Services.YMMV的经验

检索URL参数-控制器/资源类。

您的控制器需要从
$this->getEvent()

其次,只有module.config.php上批准的参数才能通过Apigility.Notice Collection Query白名单的验证器/过滤器部分

module.config.php
在服务的模块文件夹中

'ServiceName\\V1\\Rest\\ServiceName\\Controller' => array(
            ...
            'entity_http_methods' => array(
                0 => 'GET',
                1 => 'PATCH',
                2 => 'PUT',
                3 => 'DELETE',
            ),
            'collection_http_methods' => array(
                0 => 'GET',
                1 => 'POST',
            ),
            'collection_query_whitelist' => array(
                0 => 'username',
                1 => 'entity_provider',
                2 => 'entity_type',
                3 => 'entity_date_range',
                4 => 'sort_by',
                5 => 'sort_order'
            ),
            ...

测试它,让我回复你哦,是的,我实际上发现Apigility editor允许你通过它的编辑器将这些参数列为白名单。一旦我将参数列为白名单,它就会完全按照你在这里写的那样做。然后我想在连接了数据库而不是连接了代码的数据库中做这件事……即使我确实移动到了连接了代码的数据库中,它仍然会这样做不是真的回答了这个问题,是吗?反正我会记下来的。对不起,我帮不了DB Connect,我很少(除了在教程中)使用它们。别这样!你还是在某种程度上帮助我实现了我的目标。
'ServiceName\\V1\\Rest\\ServiceName\\Controller' => array(
            ...
            'entity_http_methods' => array(
                0 => 'GET',
                1 => 'PATCH',
                2 => 'PUT',
                3 => 'DELETE',
            ),
            'collection_http_methods' => array(
                0 => 'GET',
                1 => 'POST',
            ),
            'collection_query_whitelist' => array(
                0 => 'username',
                1 => 'entity_provider',
                2 => 'entity_type',
                3 => 'entity_date_range',
                4 => 'sort_by',
                5 => 'sort_order'
            ),
            ...