single & multiple record insert to parent/child tables
Here’s my scenario, which must be fairly common...
I am creating a site with member access only, where members can have several contact email addresses.
So I added tables members (parent) and memberscontact (child) to my database, child table to store members email address, with fields, MembercontactID, MemberID (FK to members table) and EmailAddress.
What I want to do is add a single record insert behavior for all of the fields for the members table, and a multiple record insert behavior for the email details, using the same memberid as inserted into the members table. (memberID in member table is PK, auto increment).
When I have done something like this before, I always used a lookup query to check the maximum ID of the members (parent) table and inserted the next incremental value into my child table.
With Dataassist 2, I would create a single insert record behaviour first, then code the multi insert behavior according to the solution recipe.
My question is 2 fold.
1. what is the best approach for inserting child records by this method, I feel the lookup query method isn’t the best way. (eg i think ecart uses mysql_insert_id ?) and
2. do i need to lock tables / use transactions to ensure data integrity ?
Thanks