Forums

Multi DB Save

U Can Drive 07 Feb, 2016
Here's a strange one for you.

Occasionally I have a student that does more than 10 lessons, sometimes up to 80.

During the registration process I have a form that creates a blank table for 10 lessons.

Rather than try and make that form work for all 80 lessons I am trying to save it 8 times under a different table name:
Lessons01-10
Lessons11-20
etc...

I've done this using multiple DB Save functions under the "On Submit" event (see image), it does save the first one but then does not save the rest.

Have I missed something? Or is there another way to do this.
U Can Drive 07 Feb, 2016
Yes, the different tables all have the same field names...
GreyHead 07 Feb, 2016
Hi U Can Drive,

The best answer is don't do it like this. Use one single table for all of the lessons for all of the pupils. MySQL is more than capable of handling that structure and volume of records. They way you are going just makes the forms more and more complex and messy to manage and query.

That said the problem you are seeing is probably because after the first DB Save the id is added to the form data and the subsequent DB Saves are probably over-writing the record with that ID. Adding a Debugger should show you the queries that are being created and adding custom code between the DB Saves to unset the id value should allow new records to be created.

Bob
U Can Drive 07 Feb, 2016
Yeah, I did consider that but most students don't have that many lessons and breaking it up does feel easier to manage when that much data is not normally used. In 7 years I've only had 3 use that many.

I use Joomla! because I don't have the programming skills, could you please show me what I would need in the custom code box.

Thank you

Seriously, for all the help you have been I'm buying you a coffee.
GreyHead 08 Feb, 2016
Hi U Can Drive,

Thanks for the coffee.

Please see this FAQ for the unset code.

Bob

PS I'd use two tables in total, one for students, the second for lessons.
U Can Drive 08 Feb, 2016
Thanks for that, the code actually gave me a much better plan.

As the Instructor I open their Student file clear the id and transfer their license number to the lessons form and create it myself.
That way if they only have the 10 lessons forms 2-8 are never even created.

I can also use that code to make clear the vouchers when I get back to those.
This topic is locked and no more replies can be posted.