Welcome Guest, Not a member yet? Register   Sign In
Model sharing variables in functions? [solved]
#4

[eluser]ywftdg[/eluser]
Not sure, all I know is change that query to like yours,and it broke again, haha. My current code is working, is:

Code:
class Reports_model extends Model {

        var $rate = '';
        
       /////////////////////////////////////////////
       function Reports_model()    {
         parent::Model();
        
    }
  
    
    /////////////////////////////////////////////
    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();
        
        //    Set Rate
        $row = $query->row();
        $this->rate = $row->dPercentages;
        
        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*sum(oQuantity)) as salesTotal, ((oPrice*' . $this->rate . '/100)*sum(oQuantity)) as salesProfit');
        
        $this->db->order_by('quan', 'desc');
        $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();
        
       }
    
    
    
    
       /////////////////////////////////////////////
    }

Basically I gotta grab stuff from 3 tables, staring with finding things related to the user id (comes from session sent from controller, $id). That then says, ok get what is the rate they make of sales, then get whatever products they have, where are those products on the orders, count how many times that happens and amounts to, and boom show it in the view. Total circus act really, old system, but it works I assume..


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



Theme © iAndrew 2016 - Forum software by © MyBB