Skip to content
Advertisement

Prepared statement with some where condition in case of any value

I have prepared statement like

and i cant figure out what to do, if user select option “any author” or “any theme”, what should i set to prepared statement?

Advertisement

Answer

This is a case for “dynamic SQL”. You can do it manually, or use an ORM.

Let’s see the manual case:

Now, if you have 10 parameters, an ORM really helps a lot. Pretty much all of them support dynamic SQL in a really nice way.

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