<?php 
class Navbar_Model extends Model{
	function __construct(){
		parent::__construct();
	}
	function insert($data){
		return $this->db->insert("navbar",$data);
	}
	function update($data,$id){
		$this->db->where("navid",$id);
		return $this->db->update("navbar",$data);
	}
	function delete($navid){
		$this->db->in("navid",$navid);
		return $this->db->delete("navbar");
	}
	function get($navid=false){
		if($navid){
			$this->db->where("navid",$navid);
		}
		$this->db->orderby("order","DESC");
		return $this->db->get("navbar");
	}
	function catlists($all){
		$html	=	new Html_Model();
		$arr	=	array();
		foreach($all as $channelid=>$cats){
			$arr[]	=	array("url"=>$html->url($channelid,$catid=0,$contentid=0),"name"=>$this->db->where("channel_id",$channelid)->get("channel")->current()->channel_name);
			foreach($cats as $cat){
				$arr[]=	array("url"=>$html->url($channelid,$cat['cat_id']),"name"=>$cat['cat_name']);
			}
		}
		return $arr;
	}
}