I’m pretty new to codeigniter and I am trying to get to know databases better so I decided to follow this guide.
However I want to go a bit more advanced and try it over multiple pages with multiple tables, I have sort of got it half working but when I click add to cart it always selects the item from database 1. It uses
$this->db->where('id', $id);
$query = $this->db->get('fruit', 1);
to add the item to the cart. But I want it to be able to select from more than one table eg. fruit and veg where they would both be in a different table but have the same columns, is there anyway to easily do this using joins or any other method?
Yes, have you look into codeigniter active record?
Edit:
From your description in your comment, I constructed these two tables.
This is an example of the function test using multiple and joins. I think this is your final sql query?
And this is the corresponding codeigniter query.