Radicore Forum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » RADICORE development » Application Development » 2 Grandparents, 2 Parents and 1 Child table (How best to copy data from multiple parent tables to a child table)
UPDATE: 2 Grandparents, 2 Parents and 1 Child table [message #3814 is a reply to message #3813] Fri, 02 August 2013 05:38 Go to previous message
haider.faraz is currently offline  haider.faraz
Messages: 15
Registered: July 2013
Junior Member
I have solved this problem as follows:

  1. I made the planofstudycourses table a parent to the courses table
  2. I added the field 'planofstudycoursesID' to the courses table to relate it to the parent planofstudycourses table
  3. I made the screen in step (b) a MULTI 2 screen
  4. I made the courses table a link table between the academicsession table (outer table) and the planofstudycourses table (inner table)
  5. 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'
  6. I made the 'course_class_and_section' field non-mandatory in the courses table
  7. 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;
}
 
Read Message
Read Message
Read Message
Previous Topic: Button on a detail record of a list transaction pattern
Next Topic: New window for graphics
Goto Forum:
  


Current Time: Fri Mar 29 04:46:43 EDT 2024

Total time taken to generate the page: 0.00840 seconds