[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?