<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');


class Affiliate_m extends CI_Model

{

    public function __construct()

    {
        $this->load->database();
    }

    public function add_affiliate_income($user_id,$product_code,$price,$percentage,$income)
    {
    
      $query = $this->db->query("INSERT INTO `affiliate_income`(`user_id`, `product_code`, `price`, `percentage`, `income`) VALUES ('$user_id','$product_code','$price','$percentage','$income')");
      
    }
    public function add_affiliate_income_intotal($user_id,$income)
    {
    
       $this->db->query("UPDATE `total_balance` SET `other_earn_amount`= other_earn_amount + '$income' WHERE user_id = '$user_id'");
       $this->db->query("INSERT INTO `other_earned`( `user_id`, `amount`) VALUES ('$user_id','$income')");
    }

    public function all_income_history($user_id)
    {

        $qury = $this->db->query("SELECT * FROM `affiliate_income` WHERE user_id='$user_id'");

        return $qury->result();
    }


}