Thursday, June 2, 2011

BB2.0 Imports : Adding linked data on-the-fly

For a while now I have wanted to be able to add data to other tables via the standard BB2.0 CSV import functionality.

For example, if I am importing staff data, it would be great if I could import the user linked to the staff data at the same time, rather than having to import the user first and then import the staff data separately.

This has led to the addition of a nifty noew import syntax for bb2.0 imports, namely add_linked_data_ which allows you to add extra columns to your CSV import spreadsheet which look like this:

add_linked_data_userISbb_usersID.first_name or 
add_linked_data_userISbb_usersID.last_name

The presence of these columns will force the import script to check to see if a field exists in this import called

userISbb_usersID

and if so, to try to add the new data found in these columns to the database BEFORE importing the current line of data, and thereafter linking the field  userISbb_usersID to the newly added data. If it finds that the data already exists (it may have been added a few lines previously for another row in the import) then it simply links this row's data to the existing entry.

No comments:

Post a Comment