06-13-2017, 05:39 PM
Hi folks, what do I need to make a form like master / detail (2 tables) in Us 4.2 ? Which required packages I need to load in a new form ?
Thanks everybody
Thanks everybody
The following warnings occurred: | ||||||||||||
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
|
form standard in 4.2
|
06-13-2017, 05:39 PM
Hi folks, what do I need to make a form like master / detail (2 tables) in Us 4.2 ? Which required packages I need to load in a new form ?
Thanks everybody
06-14-2017, 11:35 AM
Hmm. I'm not sure exactly what you're talking about. You don't need anything special to do this.
You want to tie the two tables together with some sort of id, so... Let's just say you have table 1 called master, your columns would look like id (int 11, auto incremented) //then whatever other columns you want Then I'm assuming that you want table two to possibly have many lines that all connect to the master table. This one is called details That one would have id (int 11, auto incremented) master_id (int 11) //then whatever other columns you want So, you would do your inserts in two steps... Code: $fields = array( Code: your_data=>"the_actual_data" Code: ); Code: $db->insert('master',$fields); Code: $master_id = $db->lastId(); So now you do your second query Code: $fields2 = array( Code: master_id = $master_id, Code: your_data=>"the_actual_data" Code: ); Code: $db->insert('details',$fields2); This video is about 30 minutes, but I think it will save you a lot of time in the long run... https://userspice.com/documentation-db-class/
06-19-2017, 04:55 PM
Thank you Dan, your suggestion help me a lot. Execelent tutorial.
Hugs
06-20-2017, 11:35 AM
Awesome! Glad it helped!
|