<?php
class FocusModel{
	private $_model;
	public function __construct(){
		$this->_model = ZibanmaModel::get_instance();
	}
	
	/**
	 * 添加焦点图
	 */
	public function zibanma_focus_add($post){
		if($post){
			return $this->_model->_db->execute("insert into [prefix]focus (title, target, url, sort, create_time, image) values ('{$post[title]}', '{$post[target]}',  '{$post[url]}', 0, now(), '{$post[image]}'); ");
		}
		return null;
	}
	
	/**
	 * 获取焦点图列表
	 */
	public function zibanma_focus_list($sort='asc'){
		return $this->_model->_db->query("select * from [prefix]focus order by sort {$sort}; ");
	}
	
	/**
	 * 更新排序
	 * @param $arr id/value
	 */
	public function zibanma_update_sort($arr){
		if($arr){
			return $this->_model->_db->execute("update [prefix]focus set sort={$arr[value]} where id={$arr[id]}; ");
		}
	}
	
	/**
	 * 删除焦点图
	 */
	public function zibanma_delete($id){
		if($id>0){
			return $this->_model->_db->execute("delete from [prefix]focus where id={$id}; ");
		}
		return null;
	}
	
}
?>