Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using LIKE with RAWQUERY #1039

Open
eduo opened this issue Nov 27, 2024 · 1 comment
Open

Using LIKE with RAWQUERY #1039

eduo opened this issue Nov 27, 2024 · 1 comment

Comments

@eduo
Copy link

eduo commented Nov 27, 2024

Hi, there.

Been a happy user for many years but today I had the need to do a rawquery that requires like with wildcards and I just couldn't make it work.

For various reasons I need to use rawquery for this specific query, but the string to search by must match only the end of the field, so normally I'd use LIKE '%endstring'.

In Rawquery parameters are encoded by using a question mark and then an array of values replacing the question marks in order.

But doing it this way breaks here. LIKE %? will end up sent as LIKE %'endstring' and LIKE '%?' will end up completely break.

I could do something ugly like LIKE '%".$endstring."'" but this kind of defeats the purpose.

@palsypentertainment
Copy link

If you want to escape a var, can't you do something like

$endstring = $this->db->escape( $enstring );

Then you can do LIKE '%".$endstring."'"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants