Entity-attribute-value model using codeigniter / php
- by John Stewart
SO I am trying to create a way to structure my database to be able customize forms.
I looked into EAV pattern and here is my db structure:
Table form
- form_id
- form_name
- form_added_on
- form_modified_at
Table: form_fields
- field_id
- form_id
- field_type (TEXT, RADIO etc..)
- field_default_value
- field_required
Table: form_data
- data_id
- field_id
- form_id
- field_value
so now I can store any custom form into the database and if I want to get the values for an individual form I can simply join it by "form_id" ..
the problem:
I want to be able to search through all the forms for a specific field value.
How can I do that with EAV model?
Also, I thought about just storing the custom data as a serialized (JSON) object but then I am not sure how can I query that data.
Please note that I am using Codeigniter with MYSQL. So if conversation can use Codeigniter libraries if needed.