How to get data from 2 related tables in the same controller? |
I'm trying to get data from 2 DB tables that are related. Departments and Functions: Each Department has multiple Functions.
I want to show all data in an accordion on the same page. Until now, the code works like this: Declare the variable departments in the controller, and in view, in the foreach loop, I have called the Functions model in a variable. Controller: Code: public function index(){ Here I want to add the Function->get_by_department_id() method. How to get the ID dynamically? The occupation model method: Code: public function get_by_fk($table = 'occupations', $fk = "department_id" , $fk_value=$department->department_id){ |
Messages In This Thread |
How to get data from 2 related tables in the same controller? - by dragoshjianu - 07-09-2019, 12:55 PM
RE: How to get data from 2 related tables in the same controller? - by Wouter60 - 07-09-2019, 11:44 PM
RE: How to get data from 2 related tables in the same controller? - by neuron - 07-09-2019, 11:50 PM
RE: How to get data from 2 related tables in the same controller? - by dragoshjianu - 07-11-2019, 11:38 PM
|