Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#331 2018-06-26 15:51:02
- jeroenvg
- Member
- From: netherlands
- Registered: 2010-04-21
- Posts: 33
Re: smd_query: Talk to the database directly via SQL
jeroenvg wrote #311942:
does smd_query cache results?
think i found what’s going on. from looking at mysql query log, i can see smd_query asking for the current score from my table when the page with html form is rendered. but for the (new, uncached) ‘thank you’ page, the query is not repeated.
so, the ‘thank you’ page gets the counter value somewhere else. could it be that they’re carried over from the html form?
if so, is there a way to clear smd_query values beforehand, to make the ‘thank you’ page query my table again?
Offline
#332 2018-08-31 08:28:40
- aslsw66
- Member
- From: Geneva, Switzerland
- Registered: 2004-08-04
- Posts: 338
- Website
Re: smd_query: Talk to the database directly via SQL
I’m back in the land of Textpattern after a long break!
I have a page that returns results from the database – in this case, a list of incidents. I have a form that allows the user to filter the list according to the type of incident – a fire, a community event or a controlled burn. Or everything. The form posts the selection in a URL variable called ‘type’.
Here’s my code so far:
<txp:smd_query query="SELECT id, date_format (date_out,'%d/%m/%Y') as date, type, description, location FROM gck_incidents where type like '?type' order by date_out desc" limit="25" urlfilter="/(\ball\b)/" defaults="type:%" pageform="page_info">
This works perfectly for any selected value, but if the user leaves the value as the default of ‘all’ then nothing is returned. I’m still trying to figure out regular expressions so I know this needs more work to stop users adding anything else they want to the URL. But for testing purposes it would be good to at least get this working.
Last edited by aslsw66 (2018-08-31 08:29:20)
Offline