Alex Rivera | Logout

Is there a Entity Attribute Value (EAV) framework out there for PHP/MySQL?

Asked 2008-10-22T00:31:39.647
21

Is there a Entity Attribute Value framework out there for PHP/MySQL? I'm starting to write my own, but I feel like its been done already. Any suggestions?

Edit
Report

2 Answers

1

There does not currently appear to be an EAV Framework in PHP / MySQL; however, I did find these two links that might be of some assistance:

http://www.planetmysql.org/entry.php?id=14025

http://www.iwilldomybest.com/2008/08/php-mysql-tip-3/

answered 2008-10-31T04:48:48.743
1

I don't know of any.

With that said, the eZ Publish ECMS (which is FOSS) uses an EAV-style, heavily normalized data model. Both definitions of types of structured content ("content classes") and actual instances of content (articles, user accounts, comments, products, anything really) are defined and stored in single database tables.

This way, arbitrary combinations of datatypes can be dynamically combined through the web interface to make a new content type (a "simplearticle" might consist of a "Textline" for headline, "Datetime" for publish date and "XML field" for body text). In EAV, "simplearticle" is the entity, "headline" an attribute name and "Textline" its value, while the length and validation rules comprising the "Textline" datatype are metadata in the EAV context.

As expected with any EAV architecture, this flexibility comes at the cost of reduced performance, since any lookup requires multiple self-joins, one for each column in the pivoted result set.

Unfortunately, this stack hasn't make it into eZ's related eZ Components library (which has database and data access object/ORM components, but of the standard relational variety), so using it would mean either dealing with the whole eZ Publish enchilada or ripping the required class libraries out yourself.

answered 2008-10-31T10:43:32.300

Your Answer