This topic is locked

How to get Detail table Name that has records (Edit/Add page)

12/29/2015 5:40:51 AM
PHPRunner General questions
R
rockrockers23 author

I have 1 master table linked to many details (pls note I have more than 10 Details under 1 Master).
It works the same way the List Page display of details tables (Show only the Details table with records) ONLY that I'm working on EDIT/ADD page.

Meaning, only 1 Detail table will display on every Master. The rest of the hidden Details table are empty or no records.
Question:

  • How to get specific Detail table that is currently showing on my Edit/ADD page? In other words, how to get the Detail(Table) name that has records?
    My main purpose is to save the values under my Master table to the currently showed Detail fields.

Sergey Kornilov admin 12/29/2015

The most reliable way to do so is to perform a SQL query manually retrieving the number of details records that belong to this specific master record. If you have multiple details tables you will have to execute one SQL query for each table.
The best place to put this code is one of server side events. Note that you can only do that on the Edit page as on the Add page there is no data yet.
Here is the sample code for Edit page: Process Record Values event. We use the typical master-details relationship between Orders and OrderDetails tables:

$num = DBLookup("select count(*) from OrderDetails where OrderID = " . $values["OrderID]);


More info on this event:

http://xlinesoft.com/phprunner/docs/process_record_values.htm