arrange conditionals for a SQL query [closed]

1

I have the following SQL statement to search the database:

$query = "SELECT * FROM table WHERE MATCH(title,content,tag) AGAINST(? IN BOOLEAN MODE)";

but there are some options that can be turned on, such as limiting the amount of results, filtering from lowest to greatest , filter by column value

The logic I'm currently using is something like this:

if($limit)
$query .= " LIMIT {$limit}";

for all optional values.

Is there any more efficient way to change the value of $query when you have many "IFs"?

NOTE: Many of these filters can be used at the same time.

    
asked by anonymous 30.08.2016 / 02:36

0 answers