When I execute something like
SELECT users.name FROM users ORDER BY name
I get table where each row it's a user_name.
What if I need to display all names in a single row (maybe with comma after each)?
Hi Pavel,
Thank you for using PocketQuery!
What you are looking for is a custom template. You can assign a template to each of your query that defines the way its result is displayed. Templates consist of arbitrary Velocity code and are very powerful.
For your query, it could be something basic like this:
#foreach($row in $result) ${row.name}#if($velocityCount < $result.size()),#end #end
This template goes through all rows and prints only the "name" attribute. Additionally, to avoid a comma behind the very last element, it uses the loop counter provided by Velocity ($velocityCount).
You can find more information on templates in the PocketQuery Documentation, where you can also have a look at the code of the PocketQuery default template. But for an easy start I highly recommend you to have a look at our Quick Start Guide or the Templating Tutorial.
Hope this helps? Let me know if you need further help!
Best regards
Carla
Thank you Carla, your code does exactly what I wanted!
I'd like to know if it possible to use datepicker for :parameters in query when you construct select query for range of dates? It's a bit annoying to fill each time fields From: 2017-02-01 and Till: 2017-02-20.
Thank you for accepting my answer, I'm happy to hear I was able to help!
I'm not sure I understand what you mean - where exactly would you like to have a datepicker? Within the code editor for writing SQL statements in the PocketQuery administration? Or when adding the PocketQuery macro to a page and setting the parameter values?
When you create query in PocketQuery Administration you can useĀ :params.
When you add macro with above query/statement then you can tick Use change params template and Enable dynamic parameters so after saving the page PocketQuery macro shows input fields(form) on the page. So user can pass some values to query.
It's very often that you query something for the range of dates. This is why it'll be useful to have datepicker for such case.
It looks like you're new here. Sign in or register to get started.