The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/showthread.php 28 require_once





× This forum is read only. As of July 23, 2019, the UserSpice forums have been closed. To receive support, please join our Discord by clicking here. Thank you!

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
form standard in 4.2
#1
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
  Reply
#2
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);
THEN you need to get that id back
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/
  Reply
#3
Thank you Dan, your suggestion help me a lot. Execelent tutorial.
Hugs
  Reply
#4
Awesome! Glad it helped!
  Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)