<?php 



class banner {

	

	function getAllRecords($all='*',$where='',$orderby='',$limit=''){

		

		$sql ="select $all FROM tbl_banner WHERE 1=1 "; 

		if($where!=''){

			$sql .= " AND $where ";

		}

		

		if($orderby!=''){

			$sql .= " $orderby ";

		}

		

		if($limit!=''){

			$sql .= " $limit ";

		}

		

		return connection::execute($sql,'select-all');

	}

	

	function getAllbannerFromIds($ids=null){

		if($ids!=null){

			$sql ="select * FROM tbl_banner WHERE FIND_IN_SET(banner_id,'$ids')";

			return connection::execute($sql,'select-all');

		}	

	}

	

	function fromId($id){

		

		if($id && !is_null($id)){

			$sql ="select * FROM tbl_banner WHERE banner_id = $id"; 

			return connection::execute($sql,'select');

		}

		return false;

	}

	

	function addRecords($data){

		

		if($data && count($data) > 0){

			$sql ="INSERT INTO tbl_banner(banner_title,banner_image,banner_thumb_text,banner_text,banner_created_date,banner_status)  VALUES ('".$data->banner_title."', '".$data->banner_image."', '".$data->banner_thumb_text."', '".$data->banner_text."',NOW(),'".$data->banner_status."' )";

			return connection::execute($sql,'insert');

		}

		return false;

	}

	

	function updateRecords($data){

		

		if($data && !is_null($data)){

			$sql ="UPDATE tbl_banner SET banner_title = '".$data->banner_title."',banner_image = '".$data->banner_image."', banner_thumb_text = '".$data->banner_thumb_text."',banner_text = '".$data->banner_text."',banner_status = '".$data->banner_status."' WHERE banner_id = ".$data->banner_id;

			return connection::execute($sql,'update');

		}

		return false;

	}

	

	function changeStatus($banner_id,$status){



		if($status==0){

			$new_status = 1;

		}else{

			$new_status = 0;

		}

		$sql ="UPDATE tbl_banner SET banner_status = '".$new_status."' WHERE banner_id = ".$banner_id;

		return connection::execute($sql,'update');

	}

	

	function deleteRecord($banner_id){

		$sql ="DELETE FROM tbl_banner  WHERE banner_id = ".$banner_id;

		return connection::execute($sql,'delete');

	}

	

	function allAction($act_val,$checkArr){

		

		if($act_val=='delete_all'  && $checkArr && count($checkArr) > 0){



				$sql ="DELETE FROM tbl_banner  WHERE banner_id IN(".implode(',',$checkArr).") " ;

				return connection::execute($sql,'delete');

				

		}else if($act_val=='activate_all' && $checkArr && count($checkArr) > 0){

				

				$sql ="UPDATE tbl_banner SET banner_status = '1'  WHERE banner_id IN(".implode(',',$checkArr).") " ;

				return connection::execute($sql,'update');

		

		}else if($act_val=='inactivate_all' && $checkArr && count($checkArr) > 0){



				$sql ="UPDATE tbl_banner SET banner_status = '0'  WHERE banner_id IN(".implode(',',$checkArr).") " ;

				return connection::execute($sql,'update');

		}

	}

	

}



?>