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 3 of 3 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 14 R0002 2019-04-01 David Dhhhhh Mars Male 2019-04-02 testemail@gmail.com +911343213233 Lorep ipsum address Lorep ipsum address 452005 ca ca USA o+ Cal USA 100001 English 1 1 none Lorep ipsum address na 1 13 0 1 xyz 1 1
2 15 R0003 2019-04-01 Mark D Tasr Male 2019-04-02 testemail@gmail.com +911343213233 Lorep ipsum address Lorep ipsum address 452005 ca ca USA o+ Cal USA 100001 English 1 1 none Lorep ipsum address na 3 15 0 1 xyz 1 1
3 16 R0004 2019-04-01 Kelvin D Kale Male 2019-04-02 testemail@gmail.com +911343213233 Lorep ipsum address Lorep ipsum address 452005 ca ca USA o+ Cal USA 100001 English 1 1 none Lorep ipsum address na 4 16 0 1 xyz 1 1
# 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