View file news/app/Models/Admin_Model.php

File size: 885B
<?php

class Admin_Model extends Controller
{
	function news_exist_sql($key, $value)
	{
		return count($this->db->exec("SELECT `".$key."` FROM `".$this->prefix."-news` WHERE `".$key."` = '{$value}' LIMIT 1"));
	}
	
	function news_add_sql($news_title, $news_text, $news_date)
	{
		if($this->db->exec("INSERT INTO `".$this->prefix."-news`(`news_title`, `news_text`, `news_date`) VALUES('{$news_title}', '{$news_text}', '{$news_date}')"))
		{
			return true;
		}
		else
		{
			return false;
		}
	}
	
	function news_count_sql()
	{
		return count($this->db->exec("SELECT * FROM `".$this->prefix."-news`"));
	}
	
	function news_list_sql($limit)
	{
		return $this->db->exec("SELECT * FROM `".$this->prefix."-news` ORDER BY news_id DESC $limit");
	}
	
	function news_delete_sql($news_id)
	{
		return $this->db->exec("DELETE FROM `".$this->prefix."-news` WHERE `news_id` = '{$news_id}'");
	}

}