• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Model sharing variables in functions? [solved]

#1
[eluser]ywftdg[/eluser]
I seem to be having a hard time on this dang project, one after another. I have two functions in my model, but for no matter what, I cannot figure how to pass the query result to the other one.

Code:
function get_royalty_rate($id)    {
        $this->db->select('dPercentages');
        $this->db->where('designer.dDesignerId', $id);
        $this->db->limit(1);

        $this->db->from('designer');
        $query = $this->db->get();
            $row = $query->row();
            $rate = $row->dPercentages; // trying to set a variable for the result
        return $query->result();
       }

function get_products($id)    {
        
        $this->db->select('pSku,oSku,oName,oPrice,rTimeStamp,pDesignerId');
        $this->db->where('products.pDesignerId', $id);
        $this->db->group_by('oSku,oPrice');
        
        $this->db->select('pSku,pName,oPrice,oSku,rTimeStamp, sum(oQuantity) as quan, ((oPrice*' . $rate . '/100)*sum(oQuantity)) as salesProfit');
// the $rate in this query is my problem
        

        $this->db->from('products');
        
        $this->db->join('orderdetail', 'orderdetail.oSku = products.pSku');
        $this->db->join('receipt', 'receipt.rOrderNum = orderdetail.oOrderNum');
        
        
        $query = $this->db->get();
        return $query->result();
        
       }

Any ideas?


Messages In This Thread
Model sharing variables in functions? [solved] - by El Forum - 08-05-2008, 01:35 AM
Model sharing variables in functions? [solved] - by El Forum - 08-05-2008, 01:43 AM
Model sharing variables in functions? [solved] - by El Forum - 08-05-2008, 01:48 AM
Model sharing variables in functions? [solved] - by El Forum - 08-05-2008, 02:20 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.