generic csv import for tables relationships to other tables
Posted: Tue Mar 09, 2010 3:13 am
Hi,
I'd like to know if there is an easy way for me to develop a generic csv import function that would be able to reference the same relationships I've defined for new records in Xataface with valuelists feeding the fields.ini file.
For example, imagine the following 2 tables:
Now imagine I have a csv file:
I'd like to know how I could know from a generic import_csv file (stored in each table delegate class) what the relationships defined in valuelists.ini and fields.ini are such that I could:
1) check for validity of the input (i.e. does black exist in the category table or not)
2) input the correct value for the table (i.e. input "1" into the third column, rather than "black").
For now, I don't have a problem copying this generic import_csv to all table delegate classes, but it would also be nice if I could somehow centralize this script and call from each table delegate class (I'm a php novice).
Thanks,
Rich
I'd like to know if there is an easy way for me to develop a generic csv import function that would be able to reference the same relationships I've defined for new records in Xataface with valuelists feeding the fields.ini file.
For example, imagine the following 2 tables:
- Code: Select all
Table category
id category_type
1 black
2 red
3 yellow
Table jelly_bean
id name category
1 lemon 3
2 cherry 2
3 strawberry 2
Now imagine I have a csv file:
- Code: Select all
Tablename,jelly_bean
liquorice,black
raspberry,red
I'd like to know how I could know from a generic import_csv file (stored in each table delegate class) what the relationships defined in valuelists.ini and fields.ini are such that I could:
1) check for validity of the input (i.e. does black exist in the category table or not)
2) input the correct value for the table (i.e. input "1" into the third column, rather than "black").
For now, I don't have a problem copying this generic import_csv to all table delegate classes, but it would also be nice if I could somehow centralize this script and call from each table delegate class (I'm a php novice).
Thanks,
Rich