⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

one to many relation



redhen_07
  • profile picture
  • Member

Posted 22 July 2013 - 01:37 AM

thank you for this great library

 

i have a question is it possible to have one is to many relation (parent and child)

 

example faculty have clearance per year

 

this is my sample table

 

faculty

        id

        fname

        lname

        campus

        school

 

clearance

        id

        faculty_id (related to faculty table id)

        clearance

        year

 

on my clearance view

 

i use this to get fname and lname

$crud->set_relation('faculty_id','faculty_list','{lname}, {fname}');

 

now my question:

    how can i get the other info from faculty table like campus and school on my clearance view in a different column

 

or do i need to create campus_id and school_id on my clearance table and set a relation,, is this a good i dea


davidoster
  • profile picture
  • Member

Posted 22 July 2013 - 05:42 AM

Hello and welcome to the forums [member=redhen_07].

Exactly this case is a typical case where a set_relation helps us to bring information from other tables.

And yes, in order to make this to work, you will need to alter your table  cleareance and add as many fields are needed

(campus_id and school_id) and build the relations for them.


redhen_07
  • profile picture
  • Member

Posted 22 July 2013 - 06:25 AM

thank you so much david.