1

I have a basic CRUD endpoint, and I want to be able to search by arbitrary fields in my database. Is there a way to allow this without specifying every possible filter in the method signature?

Jesse Weigert
  • 4,714
  • 5
  • 28
  • 37

3 Answers3

0

I would just use query parameters to solve this. So just accept the fields like example.com/api/people/?name=John&age=20

Jeroen Noten
  • 3,574
  • 1
  • 17
  • 25
  • 1
    Thanks, but I was looking to support arbitrary query parameters. Restler requires me to specify every possible query parameter in the method signature. On tables with 20+ columns, this isn't really feasable or necessary. – Jesse Weigert Oct 06 '15 at 18:39
0

If you don't need to document them, you can use $request_data as a parameter, this will get all the data that is sent to the API

Arul Kumaran
  • 983
  • 7
  • 23
  • This works for POST requests, but I didn't have any luck with GET parameters. I ended up just reading from the $_GET[] structure. – Jesse Weigert Oct 07 '15 at 20:25
0

I ended up solving this by using the built in $_GET[] super global.

Jesse Weigert
  • 4,714
  • 5
  • 28
  • 37