⚠ 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

Select from multiple tables in db



Jakub
  • profile picture
  • Member

Posted 23 September 2015 - 13:33 PM

I have 3 tables in my db "employees", "sign", "subscription", and all of my tables has this same construct.

It is possible to view in one table all my records?

public function index()
{
$this->grocery_crud->set_table('employees');
$output=$this->grocery_crud->render();

$this->grocery_crud->set_table('sign');
$output2=$this->grocery_crud->render();
$this->_example_output($output2);
}

This generate 2 tables, but I want view all records from my 3 db tables in one table.

 

 

 


Amit Shah
  • profile picture
  • Member

Posted 24 September 2015 - 07:13 AM

There are 2 options to it.. 

1 if all 3 tables are same.. just merge all 3 tables into 1.. adding the type field differentiating the data. This way u wont will manage 3 different set of data into 1 single table and u will be display all 3 into 1 as u need

the second - build custom model where u will then query all 3.. make a union for it and the limit the outcome / search / etc (this 1 becomes more complex .. the earlier 1 is easiest of the approach)

 

Happy GCIng :)


Noel Calonia
  • profile picture
  • Member

Posted 24 September 2015 - 15:06 PM

i think what he mean is like in the jTable master/child row. the data in the child row is from the second table and under the ID of the main table. @amit, is it possible in the groceryCRUD datatable theme and in the datatable.js with groceryCRUD? Hope you response ASAP, thanks in advance :)