p38
Active Member
Here is a challenge for the experts...
I have run into a corner due to the way fabrik stores multiple checkbox/dropdown values in the mysql database.
If one value is selected, it stores the value in the db field as the plain value, eg: 1
If multiple values are selected, is stores them in formatted values, eg: ["1","5","10","15"]
My problem is I think it is impossible to do a query to cater for both scenarios, in order to find if a particluar item has been selected.
eg: this works fine if there is more than one selection stored.......
This will ensure I do not return 10 or 15, if I want to know only if 1 exists.
However, if only 1 value is saved in the db, eg: 1, then this query will NOT work
as it will return 1, 10, 15
So can anyone give me some tips on how to solve this.
I find it strange why fabrik does not store a single value like this ["1"] in the same format as multiple values.
Paul
I have run into a corner due to the way fabrik stores multiple checkbox/dropdown values in the mysql database.
If one value is selected, it stores the value in the db field as the plain value, eg: 1
If multiple values are selected, is stores them in formatted values, eg: ["1","5","10","15"]
My problem is I think it is impossible to do a query to cater for both scenarios, in order to find if a particluar item has been selected.
eg: this works fine if there is more than one selection stored.......
Code:
select * from list where elementvalues like '%"1"%'
This will ensure I do not return 10 or 15, if I want to know only if 1 exists.
However, if only 1 value is saved in the db, eg: 1, then this query will NOT work
Code:
select * from list where elementvalues like '%1%'
as it will return 1, 10, 15
So can anyone give me some tips on how to solve this.
I find it strange why fabrik does not store a single value like this ["1"] in the same format as multiple values.
Paul