|
|
UPDATE: 2 Grandparents, 2 Parents and 1 Child table [message #3814 is a reply to message #3813] |
Fri, 02 August 2013 05:38 |
haider.faraz
Messages: 15 Registered: July 2013
|
Junior Member |
|
|
I have solved this problem as follows:
- I made the planofstudycourses table a parent to the courses table
- I added the field 'planofstudycoursesID' to the courses table to relate it to the parent planofstudycourses table
- I made the screen in step (b) a MULTI 2 screen
- I made the courses table a link table between the academicsession table (outer table) and the planofstudycourses table (inner table)
- I removed fields from the courses table that were already present in the templatecourses table other than the instance specific fields 'course_title', 'course_class_and_section'
- I made the 'course_class_and_section' field non-mandatory in the courses table
- I copied the value of 'course_title' from the corresponding field in the templatecourses table
I also added the following function in the courses.class.inc file:
function _cm_getInitialData ($rowdata)
{
require_once 'classes/planofstudycourses.class.inc';
$dbobject =& RDCsingleton::getInstance('planofstudycourses');
$dbobject->sql_select = 'templateCourseID';
$foreign_data = $dbobject->getData("id='{$rowdata['id']}'");
$templateCourseID = $foreign_data[0]['templatecourseid'];
require_once 'classes/templatecourses.class.inc';
$dbobject2 =& RDCsingleton::getInstance('templatecourses');
$dbobject2->sql_select = 'templatecourse_title as course_title';
$foreign_data2 = $dbobject2->getData("id='{$templateCourseID}'");
$rowdata['course_title'] = $foreign_data2[0]['course_title'];
$count = $this->getCount("SELECT max(id) FROM $this->tablename");
$rowdata['planofstudycoursesid'] = $rowdata['id'];
$rowdata['id'] = $count + 1;
return $rowdata;
}
|
|
|