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

class Price_model extends MY_Model{

    public $table = 'card_price';
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * [getPriceInfo 返回折扣表中的价格]
     * @param  [type] $return_field [限定了价格表中的需要选取的字段]
     * @return [type] 关联数组      [价格表中的实效,价格]
     */
    public function getPriceInfo($return_field)
    {
        $this->db->select($return_field);
        $query = $this->db->get($this->table);
        return $query->result_array();
    } 



    /**
     * [insertInfo 价格插入]
     * @param  [type] $data [价格数组]
     * @return [type]       [布尔值 TRUE]
     */
    public function insertInfo($data)
    {
        foreach ($data as $v) {
            $insert_data = array('duration' => $v['duration'], 'price' => $v['price'], 'cid' => $v['cid']);
            $this->db->insert($this->table,$insert_data);
        }
        return TRUE;
    }


    public function deleteBycid($cid){
        $this->db->where('cid', $cid);
        $this->db->delete($this->table);
    }

    public function getById($id){
        $this->db->where('id', $id);
        return $this->db->get($this->table)->row_array();
    }
}
/* End of file price_model.php */
/* Location: /application/models/price_model.php */