Various technical articles, IT-related tutorials, software information, and development journals
Sunday, October 22, 2017
Keen Modding Live - Search levels
Today I added an API endpoint that returns information on the levels in the system, optionally filtered by ID, a substring of the title, or the owner user's ID. Allowing for multiple filters turned out to be a bit tricky because it required piecing together an SQL query at runtime, which isn't difficult if using raw SQL, but that seems treacherous, so I had to figure out how to get parameter binding to work with an unknown number of parameters. call_user_func_array worked great for making the actual bind_param call, but getting the parameter references into an array was tough because array_push doesn't like references as of PHP 5.3. Weirdly, array_merge is fine with them, so I used that to build the array of parameters.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment