Welcome Guest, Not a member yet? Register   Sign In
Solved : Newbie question - Working with models
#1

[eluser]ywftdg[/eluser]
I been bombarding the board lately, sorry I'm hitting a lot of walls lately, still very new with CI. All morning, trying to understand working in a model with a massive query that jumps around a lot. I am trying to rewrite some old php code, into a CI model now. But it seems, anytime I do a if statement on row results, it kills the model, page breaks. I was trying this:

Code:
function get_bundlestats($id,$datepost)    {
    
        $this->db->select('pSku, pName, pCost, pPrice, pSkulist');    //     grab products with skulists
        $this->db->where("pSkulist <> ''");
        $query = $this->db->from('products');
        
        
        if ($query->num_rows() > 0)    {
        
            $skulist = $query->row('pSkulist');
            
            $this->db->select('sum(pPrice)');
            $this->db->where('psku in $skulist');
            $this->db->from('products');
        }
        
       }

It breaks right when I start the if statement to check row results. Is this the wrong way to approach queries in a model? If not, why would this code be breaking? I have basically ben trying to move over the old code into this new format, sort of a translation if you may, and its quite a task. I thought it would have been easy, since the queries and function is before me in the old php code.


Messages In This Thread
Solved : Newbie question - Working with models - by El Forum - 08-11-2008, 12:26 AM
Solved : Newbie question - Working with models - by El Forum - 08-11-2008, 12:45 AM
Solved : Newbie question - Working with models - by El Forum - 08-11-2008, 01:00 AM
Solved : Newbie question - Working with models - by El Forum - 08-11-2008, 01:12 AM
Solved : Newbie question - Working with models - by El Forum - 08-11-2008, 01:20 AM
Solved : Newbie question - Working with models - by El Forum - 08-11-2008, 01:33 AM
Solved : Newbie question - Working with models - by El Forum - 08-11-2008, 01:43 AM
Solved : Newbie question - Working with models - by El Forum - 08-11-2008, 02:08 AM
Solved : Newbie question - Working with models - by El Forum - 08-11-2008, 02:15 AM
Solved : Newbie question - Working with models - by El Forum - 08-11-2008, 03:39 AM
Solved : Newbie question - Working with models - by El Forum - 08-12-2008, 12:15 AM
Solved : Newbie question - Working with models - by El Forum - 08-12-2008, 01:45 AM
Solved : Newbie question - Working with models - by El Forum - 08-12-2008, 11:44 PM
Solved : Newbie question - Working with models - by El Forum - 08-13-2008, 07:21 AM



Theme © iAndrew 2016 - Forum software by © MyBB