Skip to content
Advertisement

How to set conditions for search in prepared statements?

I am trying to create a site search in prepared statements,

Here is my code : Conditions for search

JavaScript

This is how I add it to query :

JavaScript

Here is my question. How can I use conditions safe way in prepared statements ?

Advertisement

Answer

You can build up an array of any bind parameters dynamically and then pass this to the execute()

As the only value you can bind is in the WHERE clause, you only need to alter than part…

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement