Welcome Guest, Not a member yet? Register   Sign In
Fatal memory error
#1
Sad 

When i run this query for API. I am getting allowed memory size of 134217728 bytes exhausted.

Query is

public function categories_with_products(){

        $this->db->select('category_id,category_name,parent_category');
        $this->db->from('categories_info');
        $this->db->where('parent_category', 1);

        $parent = $this->db->get();
       
        $categories = $parent->result();
        $i=0;
        foreach($categories as $p_cat){

            $categories[$i]->sub_categories = $this->sub_categories_with_products($p_cat->category_id);
            $i++;
        }

        return $categories;

      /* echo json_encode (
                    array('cat'=>$categories,
                ));*/
    }

    public function sub_categories_with_products($id){

        $this->db->select('category_id,category_name,parent_category');
        $this->db->from('categories_info');
        $this->db->where('parent_category', $id);

        $child = $this->db->get();
        $categories = $child->result();
        $i=0;
        foreach($categories as $p_cat){

            $categories[$i]->sub_category = $this->sub_categories_products($p_cat->category_id);
            $i++;
        }
        return $categories;     

    }

    public function sub_categories_products($id){

        $this->db->select('product_name,category_id');
        $this->db->from('products_info');
        $this->db->where('category_id', $id);

        $child = $this->db->get();
        $categories = $child->result();
        $i=0;
        foreach($categories as $p_cat){

            $categories[$i]->products = $this->sub_categories_products($p_cat->category_id);
            $i++;
        }
        return $categories;     

    }
Reply


Messages In This Thread
Fatal memory error - by manigopal - 11-27-2019, 07:01 PM
RE: Fatal memory error - by InsiteFX - 11-28-2019, 05:07 AM
RE: Fatal memory error - by manigopal - 11-28-2019, 05:45 AM
RE: Fatal memory error - by InsiteFX - 11-28-2019, 06:00 AM



Theme © iAndrew 2016 - Forum software by © MyBB