Well, I have a question about a mysql query using the Codeigniter Framework. I have the following tables:
Products Table
|--------|-----------------|
| id | nome_produto |
|--------|-----------------|
| 1 | Camisa Tal |
|--------|-----------------|
| 2 | Bermuda Tal |
|--------|-----------------|
Products Table - Grade
|--------|-----------------|-----------------|-----------------|
| id | tamanho | valor_item | produto_id |
|--------|-----------------|-----------------|-----------------|
| 1 | P | 35,00 | 1 |
|--------|-----------------|-----------------|-----------------|
| 2 | M | 45,00 | 1 |
|--------|-----------------|-----------------|-----------------|
| 3 | P | 22,00 | 2 |
|--------|-----------------|-----------------|-----------------|
In the query, when viewing the product, I need to display all the values of the product size. Example:
I selected product 1, in this same product we have two variations of size but with different prices, I need to bring those prices differently into the result of product visualization.
My query looks like this:
public function detalhe($id)
{
$this->db->select("prod.*");
$this->db->select("gr.valor_item");
$this->db->where('prod.slug', $id);
$this->db->join('ga845_produtos_grades gr', 'prod.id = gr.produtos_id', "inner");
$this->db->limit(1);
$query = $this->db->get('ga845_view_produtos prod');
return $query->result();
}
In this current way, instead of the query bring all the values, for example the product Shirt, it brings only the first value that would be $ 35.00 ignoring the $ 45.00. How do I resolve this?
Thanks and I hope I've explained the difficulty well.