<?PHP
class banners_SQL extends SqlRequest{

	var $table = 'banners';

	function setDefaults(){

		$_POST['date_at'] = "STR_TO_DATE('".$_POST['date_at']."', '%d.%m.%Y')";
		if($_POST['date_at_str'])
			$_POST['date_at'] = "STR_TO_DATE('".$_POST['date_at_str']."', '%d.%m.%Y')";
		$_POST['date_to'] = "STR_TO_DATE('".$_POST['date_to']."', '%d.%m.%Y')";
		if($_POST['date_to_str'])
			$_POST['date_to'] = "STR_TO_DATE('".$_POST['date_to_str']."', '%d.%m.%Y')";
		$_POST['never_expires'] = $_POST['never_expires'] ? 1 : '0';
		$_POST['is_active'] = $_POST['is_active'] ? 1 : '0';
		$_POST['position'] = $_POST['position_insert'] ? $_POST['position_insert'] : $_POST['position'];
	}

	function banners($add_sql = '', $execute = false, $cache = false){

		$this->LINE = __FILE__.' '.__LINE__;
		return $this->Select(
			"SELECT * FROM banners  ".
		$add_sql,
		$execute,
		$cache
		);
	}

	function banners_join_clients($add_sql = '', $execute = false, $cache = false){

		$this->LINE = __FILE__.' '.__LINE__;
		return $this->Select(
			"SELECT banners.*, clients.company FROM banners  ".
			"LEFT JOIN clients ON clients.id = banners.client_id ".
		$add_sql,
		$execute,
		$cache
		);
	}
}
?>