PHP Query/Comparison Method with Operators -


In my PHP page there are several variables on each weight; Their values ​​determine which widgets are displayed. Each widget has set criteria for the time it is displayed.

Example. Display the widget 'A' where:

"page == 1, page! = 3, user> 9, rank! = Blue"

  $ myVars = array (); $ MyVars ['page'] = 1; $ MyVars ['user'] = 99; $ MyVars ['rank'] = 'red';  

In this scenario I've written a simple method - it delimitates the query and compares each criteria and as soon as FALSE encounters the problem is that by my engine Any supported "or" operators are not required to meet every criteria. And I can not see my head about how the operator can be added to it.

"page == 1 || page == 2 & amp; page! = 3 & amp; user> 9 = user == 3 & amp; rank! = Blue

This will give me more flexibility on the widget, creating scenarios without making duplicate widgets separately. How do I see a parallel way of how SQL runs the queries and how do I want to query my variable - can I use a featured engine or is my fate set to write a full engine if The widget has met the criteria?

Raise your language to support or

  page = = 1 || Page == 2 & amp; Amp; Page! = 3 & amp; Amp; Users & gt; 9 || User == 3 & amp; Amp; Rank! = Blue  

will look like (CNF):

  (page == 1 || page == 2) & amp; Amp; Page! = 3 & amp; Amp; (User & gt; 9 || user == 3) & amp; Amp; Rank! = Blue  

If you want to simplify parsing, you can:

  (page == 1 || page == 2) & Amp; & Amp; (Page! = 3) & amp; Amp; (User & gt; 9 || user == 3) & amp; Amp; (Rank! = Blue)  

The DNF will look like this:

  (page == 1 & amp; page! = 3 & amp; Amp; Users & gt; 9 & amp; Rank! = Blue) || (Page == 2 & amp; Page! = 3 & amp; amp; User & gt; 9 & amp; Rank! = Blue) || (Page == 1 & amp; amp; page! = 3 & amp; user == 3 & amp; rank! = Blue) || (Page == 2 & amp; page! = 3 & amp; amp; amp; and user == 3 & amp; rank! = Blue)  

CNF is more natural Here's where


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

lua - HowTo create a fuel bar -