0
Guys, I have a question about a mysql query using the Codeigniter Framework. I have the following tables:
Table Products
|--------|-----------------|
| id | nome_produto |
|--------|-----------------|
| 1 | Camisa Tal |
|--------|-----------------|
| 2 | Bermuda Tal |
|--------|-----------------|
Products Table - Grid
|--------|-----------------|-----------------|-----------------|
| id | tamanho | valor_item | produto_id |
|--------|-----------------|-----------------|-----------------|
| 1 | P | 35,00 | 1 |
|--------|-----------------|-----------------|-----------------|
| 2 | M | 45,00 | 1 |
|--------|-----------------|-----------------|-----------------|
| 3 | P | 22,00 | 2 |
|--------|-----------------|-----------------|-----------------|
I need that in the query, when viewing the product, have a way to display all the values of the product size. Example:
I selected product 1, in this same product we have two size variations but with different prices, I need to bring these prices different to the result of the product visualization.
My appointment is 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();
}
So current, instead of the consultation bring all the values, for example the product Shirt, it brings only the first value that would be R $ 35,00 ignoring the 45,00. How do I fix it?
Thank you and I hope I explained the difficulty well.
You are limiting the query to return only one line:
$this->db->limit(1)
, so no second value appears... It would not be so?– Zulian
Unfortunately not @Zulian already tried just removing but the query result remains the same
– Saulo