Problem with custom query params

Wappler Version : v3.0.0-beta.6
Operating System : windows 10

I’m unable to use date as parameters for BETWEEN operator in custom queries.

I have a query that works fine:

but obviously I want to be able to dynamicaly change the from-to dates so I add parameters and as test values I use exactly the same dates
image
I get no results now…
image

What database are you using, how do you store the dates there and are you sure your conditions actually return results?

Testing with PHP and mysql db with datetime fields:

Screenshot_36

Entering test values:

It properly returns the results:

it’s a MySQL server; dates are stored as datetime
image
you can see in my first screenshot that the query returns results - but only when the dates are hardcoded into it…

Can you please try using a simple query like my example and check if it returns results?

same thing - it works with dates hardcoded:


but moving them to params gives no results:

Have you entered test values like that:

yeah, I’m using exactly the same values as earlier:
image

That is strange, same works in my tests.

What are your PHP version and Mysql version?

is this enough?
image

1 Like

Thanks, maybe @patrick can help here more, as i can’t recreate the issue.

thanks a lot

When used in the Server Action, does it act the same, no results?

Try replacing :P1 and :P2 in the query with ?.

it’s worth adding that this only happens in custom queries… using “between” in database query action works fine

this worked and the query gave me results
image

it works fine but can I reliably use ? in my queries?

Yes, it is the safest way to use ?. The :P1 and :P2 are also being translated to ? first, but it is not always parsed correctly. In the upcoming update we have improved it.

2 Likes

I understand I need to make sure that all the ? need to be in the same order as their respective parameters? I can live with that.
Thanks a lot for your help!

That is indeed the downside, the order and number must be exactly the same. That is why the named parameters are so popular, you don’t have to care about the order and no duplication when same value is used multiple times.

I did have a problem like this; i replaced :P2 with ? and it’s work fine now.