<?php

class lc_seo_editor_tags extends DefaultObject
{
	protected $allowed_keys=array('pattern', 'pos', 'title', 'description', 'keywords', 'walkthrough');
	
	public function __construct($id=null) {
		if ($id) $this->loadDataById($id);
	}
	
	public function loadDataById($id)
	{
		if ($data=Db::i()->selectRow("SELECT * FROM ?_lc_seo WHERE id=?", $id)) {
			$this->set($data);
		}
	}
	
	public function add($data) {
		$this->_filterKeys($data);
		$data['id']=Db::i()->query(
			"INSERT INTO ?_lc_seo (`pattern`, `title`, `description`, `keywords`, `walkthrough`) VALUES(?, ?, ?, ?, ?)",
			$data['pattern'], $data['title'], $data['description'], $data['keywords'] , $data['walkthrough'] 
		);
		$this->set($data);
		$this->update(array('pos'=>$this->id));
	}
	
	public function delete() {
		Db::i()->query("DELETE FROM ?_lc_seo WHERE id=?", $this->id);
	}
	
	protected function _updateDB(&$data)
	{
		Db::i()->query("UPDATE ?_lc_seo SET ?a WHERE id=?", $data, $this->id);
	}
	
	protected function _resetItemCache()
	{
		
	}
}