Re: Advice needed: implementing custom fields in tables

From: Date: Sat, 16 Dec 2006 02:56:25 +0000
Subject: Re: Advice needed: implementing custom fields in tables
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-245888@lists.php.net to get a copy of this message
On Tue, December 12, 2006 8:23 am, Denis Gerasimov wrote: > I am in a need of implementing custom/used-defined fields mechanism. > What I > need is adding new fileds to a db table on-the-fly. > > There are 2 possible options I know: > > 1. Add a fixed set of text columns named custom_01, custom_02, > etc. > > 2. Alter db tables dynamically by adding/dropping a column of > appropriate type and creating/dropping helper tables if needed (e.g. > values > for select lists) The "usual" answer is to create a single table of user-defined fields, and put the field_name -> field_data relationship into that. You have an extra table to JOIN to all your queries, but it works tolerably well for most usage. You may want to find out if there is a Joomla approved approach or something as well, by posting in a Joomla forum. -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So?

« previous php.general (#245888) next »