I am using PHP & jamierumbelow/codeigniter-base-model I have two tables
Table 1: Class classId classStd ----------------------- 1 Prep 3 NUR 4 STD-1 5 STD-2 Table2: Section sectionId classId section sectionName --------------------------------------------------- 5 1 A rose 6 1 B red 7 1 C green 8 3 A ROME 9 3 B PARIS
Relationship is : One Class can have many sections. My function
function section_get(){
$this->load->model('Model_section');
// this return all section with its classSTD name correctly
$pages = $this->Model_section->with('class')->get_all();
$this->response($pages);
}
Return following response
[ {"sectionId":"5","classId":"1","section":"A","sectionName":"rose","class":{"classId":"1","classStd":"Prep"}}, {"sectionId":"6","classId":"1","section":"B","sectionName":"red","class":{"classId":"1","classStd":"Prep"}}, {"sectionId":"7","classId":"1","section":"C","sectionName":"green","class":{"classId":"1","classStd":"Prep"}}, {"sectionId":"8","classId":"3","section":"A","sectionName":"ROME","class":{"classId":"3","classStd":"NUR"}}, {"sectionId":"9","classId":"3","section":"B","sectionName":"PARIS","class":{"classId":"3","classStd":"NUR"}} ]
How I can get only specific record, for example where “classId = 1”