Insert multiple rows in database

Any tips and tricks that has to with the ADDT that doesn't fit into one of the other categories
Accumike
Posts: 15
Joined: 2011-09-06 08:10

Insert multiple rows in database

Post by Accumike » 2014-11-14 12:43

We have a database that holds weekly employee shift information. There are up to 7 (daily) shifts for each job function.
Each employee shift is a different record - example fields: (user_id, user_name, date, start_time, end_time, header_id) etc.
Each week therefore consists of several records, grouped by a header record.

We add / delete shifts using ADDT with individual transactions, displayed with a do-while loop.
This works well as we can fine tune each shift as required. See screen grab:
Image

NB: We don't use the Nextensio dynamic multiple row forms as these conflict with other parts of the site, making it unreliable.

Now, to set up next week,we want to be able to copy all the shifts from this week to next week as one action. We can get all the shift information, using recordsets and repeat regions, but I am stuck on the multiple insert transaction.

Is it possible to do this with the Custom Form Wizard? Or how else might this be done?

We use the PHP / MySQL model.

Any help much appreciated.

Michael

User avatar
Fred
Site Admin
Posts: 491
Joined: 2010-02-15 12:10
Location: Armagh, Northern Ireland
Contact:

Re: Insert multiple rows in database

Post by Fred » 2014-11-15 15:36

Micheal you probably better of doing it manually.
Create a new page and apply the usual security measures

Then use

Code: Select all

mysql_query("INSERT INTO 'target_table' (column1, column2) (SELECT (column1, column2) FROM 'source_table' WHERE something = something"));
Then redirect somewhere.

Accumike
Posts: 15
Joined: 2011-09-06 08:10

Re: Insert multiple rows in database

Post by Accumike » 2014-11-25 18:55

Thanks Fred, I'll have a look at this.

Post Reply