<?php

/**
 * Created by PhpStorm.
 * User: stanley-king
 * Date: 16/6/23
 * Time: 下午9:58
 */
class member_relationModel extends Model
{
    public function __construct()
    {
        parent::__construct('member_relation');
    }

    public function getRelationList($condition = array(), $field = '*', $page = 0, $order = '', $limit = '')
    {
        return $this->table('member_relation')->field($field)->where($condition)->page($page)->order($order)->limit($limit)->select();
    }

    public function findByMobile($mobile)
    {
        $relation_info = rcache($mobile, 'member_relation');
        if (empty($relation_info)) {
            $relation_info = $this->field('*')->where(array('member_mobile' => $mobile))->find();
            wcache($mobile, $relation_info, 'member_relation');
        }
        return $relation_info;
    }

    public function replace($data)
    {
        $mobile = $data['member_mobile'];
        $this->insert($data,true);
        dcache($mobile,'member_relation');
    }

    public function replaceAll($datas)
    {
        $this->insertAll($datas,array(),true);
    }
}