I have three tables . This is done all inline.
I am trying to use newer Database API.
I would like to insert a record from Table(1) into table(2) based on field that is unique to Table(3) and Table(1) and in which Table(3) is Right Outer joined by field called class_id joined with Table(2) . Table 3 has for example 3 records with matching field in one record in Table(1).
When I look at the list page on Table(2) I can see query works as there is a list of the three items ( not saved - except 1 record is saved in database - *see below ) ( I am also using Excel like grid here ) , Since Table(1) only actually adds 1 record to database So How can I insert all 3 records to Table (2) for each record with matched Table (1) record ( class_id and flddate ) and matched records from table ( 3 ) - 3 records fields ( class_id and flddate) .
I have this for adding 1 record. Where can I use a parameter to add multiple records in new Database API?
After Add on Table(1)
// *
$data = array();
$data["class_id"] =$values["class_id1"];
$data["flddate"]=$values["flddate"];
DB::Insert("Table2", $data );
I am thinking something like this
$rs = DB::Query("select * from table3 WHERE class_id=". $values["class_id1"]." AND flddate=" . $values["flddate"]." ");
while( $data = $rs->fetchAssoc() )
// Then insert to Table(2) all three records for example from matching fields from joined Table(3)
Then redirect to those 3 records in Table 2 from Table 1 after add instead of seeing whole list on list page inline.
Table (1) and Table (2) are auto_increment keys )
but can't seem to put together both ideas above. Cannot use Update joined fields as they are not saved yet. Went through whole manual head spinning. Any Help would be highly appreciated here?
Testing with PHPRunner 10.3 34222
I am trying to use newer Database API.
I would like to insert a record from Table(1) into table(2) based on field that is unique to Table(3) and Table(1) and in which Table(3) is Right Outer joined by field called class_id joined with Table(2) . Table 3 has for example 3 records with matching field in one record in Table(1).
When I look at the list page on Table(2) I can see query works as there is a list of the three items ( not saved - except 1 record is saved in database - *see below ) ( I am also using Excel like grid here ) , Since Table(1) only actually adds 1 record to database So How can I insert all 3 records to Table (2) for each record with matched Table (1) record ( class_id and flddate ) and matched records from table ( 3 ) - 3 records fields ( class_id and flddate) .
I have this for adding 1 record. Where can I use a parameter to add multiple records in new Database API?
After Add on Table(1)
// *
$data = array();
$data["class_id"] =$values["class_id1"];
$data["flddate"]=$values["flddate"];
DB::Insert("Table2", $data );
I am thinking something like this
$rs = DB::Query("select * from table3 WHERE class_id=". $values["class_id1"]." AND flddate=" . $values["flddate"]." ");
while( $data = $rs->fetchAssoc() )
// Then insert to Table(2) all three records for example from matching fields from joined Table(3)
Then redirect to those 3 records in Table 2 from Table 1 after add instead of seeing whole list on list page inline.
Table (1) and Table (2) are auto_increment keys )
but can't seem to put together both ideas above. Cannot use Update joined fields as they are not saved yet. Went through whole manual head spinning. Any Help would be highly appreciated here?
Testing with PHPRunner 10.3 34222