<?php
/**
*	作者：信呼开发团队(雨中磐石)
*	官网：http://www.rockoa.com
*	软件：信呼在线客服系统
*	数据选项
*/
class optionClassModel extends Model
{
	
	
	/**
		获取选项
	*/
	public function getval($num, $dev='', $lx=0)
	{
		$val= '';
		$rs = $this->getone("`num`='$num'", '`name`,`value`,`id`,`optdt`');
		if($rs){
			if($lx==0)$val=$rs['value'];
			if($lx==1)$val=$rs['name'];
			if($lx==2)$val=$rs['id'];
			if($lx==3)$val=$rs['optdt'];
		}
		if(isempt($val))$val=$dev;
		return $val;
	}
	
	
	
	
	//设置选项值
	public function setval($num, $val='', $name=null, $isub=true)
	{
		$numa	= explode('@', $num);
		$num 	= $numa[0];
		$where  = "`num`='$num'";
		$id 	= (int)$this->getmou('id', $where);
		if($id==0)$where='';
		$arr 	= array(
			'num'	=> $num,
			'value'	=> $val,
			'optid'	=> $this->adminid,
			'optdt'	=> $this->rock->now
		);
		if(isset($numa[1]))$arr['pid'] 	= $numa[1];
		if($name!=null)$arr['name'] 	= $name;
		if($id==0 || $isub)$this->record($arr, $where);
		if($id==0)$id = $this->db->insert_id();
		return $id;
	}
	
	
}