Hi need to get a products value and its variant as there is one product and its variants are many, so in ordr to show the data i need the result in this format
[0] => Array
(
[id] => 4
[cat_id] => 8
[subcat_id] => 46
[manu_id] => 108
[pro_name] => sample product 1
[slug] => sample-product-1
[meta_title] => sample product 1
[meta_desc] => sample product
[pro_desc] => sample product
[feature_img] => 20181118100828.png
[feature] => 0
[view] => 0
[created_at] => 2018-11-18 10:08:34
[updated_at] =>
[variant](
[0] => [sku_no] => JMS/20181118100834/0/4
[rprice] => 2500
[sprice] => 2000
[availability] => 1,
[1] => [sku_no] => JMS/20181118100834/0/4
[rprice] => 2500
[sprice] => 2000
[availability] => 1
)
As i am using this query:
public function GetProductData($id){
$this->db->select('A.*, B.variant, sku_no, rprice, sprice, availability');
$this->db->from('products A');
$this->db->join('product_sku B','A.id = B.product_id');
$this->db->where('A.id', $id);
$query = $this->db->get();
if($query->num_rows()>0){
$results = $query->result_array();
echo '<pre>';
print_r($results);
die;
}
}
Which gives me result into this format:
Array
(
[0] => Array
(
[id] => 4
[cat_id] => 8
[subcat_id] => 46
[manu_id] => 108
[pro_name] => sample product 1
[slug] => sample-product-1
[meta_title] => sample product 1
[meta_desc] => sample product 1sample product 1sample product 1sample product 1
[pro_desc] =>
sample product 1sample product 1sample product 1sample product 1
[feature_img] => 20181118100828.png
[feature] => 0
[view] => 0
[created_at] => 2018-11-18 10:08:34
[updated_at] =>
[variant] => cotton large
[sku_no] => JMS/20181118100834/0/4
[rprice] => 2500
[sprice] => 2000
[availability] => 1
)
[1] => Array
(
[id] => 4
[cat_id] => 8
[subcat_id] => 46
[manu_id] => 108
[pro_name] => sample product 1
[slug] => sample-product-1
[meta_title] => sample product 1
[meta_desc] => sample product 1sample product 1sample product 1sample product 1
[pro_desc] =>
sample product 1sample product 1sample product 1sample product 1
[feature_img] => 20181118100828.png
[feature] => 0
[view] => 0
[created_at] => 2018-11-18 10:08:34
[updated_at] =>
[variant] => cotton medium
[sku_no] => JMS/20181118100834/1/4
[rprice] => 2500
[sprice] => 1800
[availability] => 1
)
)
I don't want to use other function into this as it will slow the process function is there any mysql solution available apart form using another function within this function.
</div>