<?php
class PicModel extends CmlModel {
	//添加图集&图片
	public function addpic($title,$url,$tags,$seo,$info,$class,$pv){
		$picok=$this->db()->set('pv', array('title'=>$title,'url'=>$url,'tags'=>$tags,'seo'=>$seo,'info'=>$info,'class'=>$class,'pv'=>$pv),true);
		$this->cache()->delete('picall');
		return $picok;
	}
	//显示修改图集&图片
	public function editpic($id){
		$picdata=$this->db()->get('pv-id-'.$id);
		return $picdata;
	}
	//修改图集&图片
	public function editpicsave($id,$title,$url,$tags,$seo,$info,$class,$pv){
		$picok=$this->db()->update('pv-id-'.$id, array('title'=>$title,'url'=>$url,'tags'=>$tags,'seo'=>$seo,'info'=>$info,'class'=>$class,'pv'=>$pv),true);
		$this->cache()->delete('picall');
		return $picok;
	}
	//删除图集&图片
	public function delpic($id){
		$picok=$this->db()->delete('pv-id-'.$id);
		$this->db()->delete('pv-class-'.$id);
		$this->cache()->delete('picall');
		return $picok;
	}
	//展示图集
	public function pv(){
		$picdata=$this->db()->table('pv')->where('class',0)->orderBy('id', 'ASC')->select();
		return $picdata;
	}
	//展示图片
	public function pvs($class){
		$picdata=$this->db()->table('pv')->where('class',$class)->orderBy('id', 'ASC')->select();
		return $picdata;
	}
	
}