Multi table relation in tabs (nested tables) of view Editing of related records in other table (Added in v 2.6)

PDOCrud allows the editing of related records of different table i.e. similar to nested table. Nested Table is a table inside a table. It is not stored in that way but similar concept is used. You can define relation between the two tables data using some binding column value.Please note that main tables must have fields present that are used for where condition to bind records. You need to enable $config["viewFormTabs"] = true; to make this work

  
                                //student table object
                                $pStudent = new PDOCrud();
                                $pStudent->setSettings("viewFormTabs", true);
                                $pStudent->multiTableRelationDisplay("tab", "Student");
                                //student's class object
                                $pStudentClass = new PDOCrud(true);
                                $pStudentClass->dbTable("class");

                                //first paramater is first table(object) columnn name and 2nd parameter is 2nd object column name
                                $pStudent->multiTableRelation("class_id", "class_id", $pStudentClass);
                                $pStudentClass->multiTableRelationDisplay("tab", "Class");

                                //student's class object - adding one more table 
                                $pStudentTransport = new PDOCrud(true);
                                $pStudentTransport->dbTable("vehicle");

                                //first paramater is first table(object) columnn name and 2nd parameter is 2nd object column name
                                $pStudent->multiTableRelation("transport_id", "vehicle_id", $pStudentTransport);
                                $pStudentTransport->multiTableRelationDisplay("tab", "Vehicle");
                                $pStudentTransport->setSettings("viewFormTabs", true);
                                //2nd level of nesting  - relating section to class(first student to class and then class to section)
                                $pStudentSection = new PDOCrud(true);
                                $pStudentSection->dbTable("section");

                                //first paramater is first table(object) columnn name and 2nd parameter is 2nd object column name
                                $pStudentClass->multiTableRelation("class_id", "class_id", $pStudentSection);
                                $pStudentSection->multiTableRelationDisplay("tab", "Section");

                                echo $pStudent->dbTable("student")->render();
                        

Student

Showing 1 to 10 of 10 entries

# Student id Register number Joining date First name Middle name Last name Gender Date of birth Email Phone Present address Permanent address Pin code City State Country Blood group Birth place Nationality Roll number Mother tongue Category id Religion Previous school Previous school address Previous qualification Class id Section id Transport id User id Password Login status Session id Actions
1 36 ooo 0000-00-00 ooo oooo 0000-00-00 oooo@gam.com 0 0 0 0 0
2 37 123 0000-00-00 a b 0000-00-00 amar@gmail.com 0 0 0 0 0
3 38 9874563210 0000-00-00 12 sdas 0000-00-00 asasd@dfgdg.fgh 0 0 0 0 0
4 39 1225 0000-00-00 msmmlm mmmmm 0000-00-00 m@gmail.com 0 0 0 0 0
5 40 1 0000-00-00 nn xy 0000-00-00 mail@tt.de 0 0 0 0 0
6 41 88888 0000-00-00 544 YY 0000-00-00 OOO@GMAIL.COM 0 0 0 0 0
7 42 100 0000-00-00 sdf sddf 0000-00-00 asfs@gmail.com 0 0 0 0 0
8 43 55 0000-00-00 Abdi Aziiz 0000-00-00 abdi@n.com 0 0 0 0 0
9 44 558 0000-00-00 Abdi Aziiz 0000-00-00 abdi@n.com 0 0 0 0 0
10 45 Yy 0000-00-00 gg hh 0000-00-00 gg 0 0 0 0 0
# Student id Register number Joining date First name Middle name Last name Gender Date of birth Email Phone Present address Permanent address Pin code City State Country Blood group Birth place Nationality Roll number Mother tongue Category id Religion Previous school Previous school address Previous qualification Class id Section id Transport id User id Password Login status Session id Actions