Feedback

How to store data into more than one DB table

Articles

To store data in different tables you have to chain different Finisher_DBs. You can use a special setting to access the uid of a previously inserted record.

finishers {
  1.class = Finisher_DB
  1.config {
    table = fe_users
    fields {
      username.mapping = lastname
    }
  }
  2.class = Finisher_DB
  2.config {
    table = tt_address
    fields {
      pid.special = inserted_uid
      pid.special.table = fe_users
      email.mapping = email
      first_name.mapping = firstname
      last_name.mapping = lastname
    }
  }
}

The first Finisher_DB stores data into the table fe_users. The second one creates a record in the child table tt_address. The pid field of this record is set to the uid of the inserted record in fe_users.

CHECK IT OUT

KEEP US HAPPY

 

Formhandler - forms for professionals

© Typoheads 2011 - forever.