Buy Now
Sign in

Advanced read data Function with filter from function

Proximate , August 17 at 09:50
For a Filter in a select function i need some kind of logic.
Actually the (Hardcoded) Filter looks somethin like that:
​AND ​
​( ​
​ home:1 ​
​ OR ​
​ visitor:1​
This results in a fixed scenario where a table is displayed with the games where team 1 is either the visitor or home team.
Now i've got a select Form on this page where the user can select (dropdown not multiple): Home, Visitor, Both (Home and Visitor Matches)
based on this selection the Query should change to:
// Scenario Visitor:​
​year_id:{data:Data.year} ​
​AND visitor=1
// Scenario Home:​
​year_id:{data:Data.year} ​
​AND home=1
So at least form the 2nd Line i have to use a Switch - but if i try to call a switch-function ({fn:xyz}) or my following switch statement (which returns value as VAR / or not both tried) the Query failes --> Undefined column {fn:xyz} or {var:xyz} - is it generally possible to call a fn inside a Filter?
To bring it all together here is my Custom Code for the switch statement (which is also not working) - same error.
​ case 'home':​
​ $query_string = ' AND home:{}';​
​ break;​
​ case 'visitor':​
​ $query_string = ' AND visitor:{}';​
​ break;​
​ case 'both':​
​ default:​
​ $query_string = ' AND ( home:{} OR visitor:{} )';​
​return $query_string;
I don't want to create the whole read_data function three times just because of a single line...
thanks for your input
Hi Proximate,
from where is coming the value of your Data.year ? Form selector or read data function? e.g. read_years