This topic is locked
[SOLVED]

 One to Many data entry

9/15/2010 2:40:32 PM
PHPRunner General questions
T
tparki authorDevClub member

I've been trying to work out how to implement a solution for the situation where I need to record a 100 or so predefined measurements for one master (boat) added. Each measurement has a spec, min value and max value which do not change for a new boat plus the actual measurement which is unique to the new boat.

I'm sure the solution is relatively simple but I would be grateful for a pointer in the right direction.

Thanks

Tim

Sergey Kornilov admin 9/15/2010

Unless I'm missing something this looks like a simple master-details relationship between two tables.
Probably you need to elaborate what exactly causes the trouble.

T
tparki authorDevClub member 9/16/2010



Unless I'm missing something this looks like a simple master-details relationship between two tables.
Probably you need to elaborate what exactly causes the trouble.



Its not trouble with the software; its trouble with getting my head around the solution!

I have a table of over 600 boats. For each boat I want to be able to add 100 or more detail records with each record having 4 fields. 3 fields are unchanging as they define the rule spec, max measurement and min measurement. the fourth field will record the actual measurement taken for that boat. So I want to be able to add the 100 detail records in one fell swoop and then enter the actual measurements in the fourth field.

Sergey Kornilov admin 9/16/2010

Sorry, still don't get what causes the trouble here.
Add master record, add as many details as you need. Sounds pretty straightforward.

T
tparki authorDevClub member 9/16/2010



Sorry, still don't get what causes the trouble here.
Add master record, add as many details as you need. Sounds pretty straightforward.



OK. The solution I have in mind means that I need to be able to append 100 measurement records from a separate table as detail records once I have added a master record for the boat. Then I can then edit each of the 100 detail records I have added with the actual measurement for that boat.

What code do I need to append the records and which is the most appropriate event to hold it?

Thanks

Sergey Kornilov admin 9/16/2010

So the question is how add 100 details records automatically after master record is created?
To do so you need to implement AfterAdd event of master table.
To insert a record use DAL's method Add():

http://xlinesoft.com/phprunner/docs/data_access_layer.htm
To insert 100 records use PHP for statement:

for($i=1;$i<=100;++$i)

{

// add one record
}
T
tparki authorDevClub member 9/20/2010

Many thanks for your patience, Sergey <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=52818&image=1&table=forumreplies' class='bbc_emoticon' alt=':P' /> Tim