CodeIgniter Forums
Two Different Querys same Model - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Two Different Querys same Model (/showthread.php?tid=13323)



Two Different Querys same Model - El Forum - 11-18-2008

[eluser]datguru[/eluser]
Hi there wondering if any of you out there can help me with a small problem.

Iam trying to use the MVC approach and it seems to be really helping me with organisation but I have run into a problem. I cant seem to do 2 lots of query's with the same model. In the below code what I am trying to do is get the raw materials first and then get the labor details afterwards and thats b change the type field. However for some reason it cant do both. Any ideas?

Thanks


Code:
$this->load->model("mdl");

        //Generate Materials for selected product
        $this->mdl->product_id = $this->uri->segment(4); //ID gained from URL to select correct product ID
        $this->mdl->type = "raw_material";
        $product_parts = $this->mdl->get();

        $data['product_parts_materials'] = $product_parts;
        
        //Generate Labor for selected product
        $this->mdl->product_parts->type = "labor";
        $product_parts2 = $this->mdl->getLabor();
        $data['product_parts_labor'] = $product_parts2;
        
        //build data to fill in form to edit
        $this->mdl_products->product_id = $this->uri->segment(4);
        //echo $this->mdl_products->product_id;
        $results = $this->mdl_products->get();



Two Different Querys same Model - El Forum - 11-18-2008

[eluser]datguru[/eluser]
Sorry ignore that, after looking over it 500 times previously and didnt notice anything I thought I would take one last look and realised that in the product parts model I had mispelled labor.

Sorry and thanks to those who looked.