language agnostic - Is it bad to perform two different tasks in the same loop? -


I am working on a high-specific search engine for my database. When a user submits a search request, then the engine splits search terms through an array and loops. Inside the loop, every investigation word is examined against several possible scenarios to examine what it can mean. When a search term matches the scenario, a WHERE status is added to the SQL query. Some words can have many meanings, and in those cases the engine prepares a list of suggestions to help the user narrow the results. On one hand: If anyone is interested in knowing this, then prefixing unrelated words can be for them with a keyword, for example, 1954 a year or a serial number. The engine will suggest both these scenarios to the user and modify the search term either in the year: 1954 or serial: 1954.

Creating SQL queries and sophisticated suggestions in the same loop, I feel something wrong, but to separate them, they should be high because I have to loop through the same array twice and Two similar circumstances must be tested. What is the better way of action?

I will probably take care of two things in my work. After this you have

  foreach (terminology word) {doThing1 (); DoThing2 (); }  

Which is nice and clean.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -