Denis Gerasimov wrote:
> Hello list members,
> 
>  
> 
> 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)
> 
>  
> 
> 1st option is not suitable for in my case because of performance issues.

1 is a horrid solution but I can't see how this is such a performance issue.
(not to say the issue does'nt exist, it's just that I don't see it)

> 
> 2nd is relatively hard to implement from scratch.

I would suggest this is easier than you imagine (you can grok all the required 
SQL
from the output of phpmyadmin, for instance) - the tricky part is getting the
database security right (which is more PITA than hard imho)

> Any ready-to-use libs or implementation ideas would be highly appreciated!
> 

3. offer an interface to define the custom fields, store the definition 
somewhere central
and use the definition to define an array (or object) which you can then 
serialize into a single
field.

4. use a 'lookup' table and a 'custom field definition' table

'lookup':

ownerid int             // FK to whatever entity owns the custom fields
CFD_id  int             // FK to 'custom field definition'
value   varchar         

'custom field definition':
id      int
name    varchar
type    varchar

you might want to create a set of lookup tables (1 for each *type* of custom 
data
you are offering the enduser) - this may offer more efficient storage and 
retrieval.



anything that is ready to use can be found via your favorite search engine, or 
sourceforge
or something like that.

> 
> FYI I am using Joomla! CMS and actually I need to create a Joomla! component
> that should also support user-defined fields.

you mean to say joomla doesn't have a plugin for this at all??

> 
>  
> 
> Have a great day,

too late, my Jean-Luc Picard has already been assimilated.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to