Entity-attribute-value model using codeigniter / php
Posted
by
John Stewart
on Stack Overflow
See other posts from Stack Overflow
or by John Stewart
Published on 2010-12-21T19:59:58Z
Indexed on
2010/12/26
3:54 UTC
Read the original article
Hit count: 344
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.
© Stack Overflow or respective owner