All pastes #470791 Raw Edit

Something

public php v1 · immutable
·published 2007-05-04 14:20 UTC
rendered paste body
function search($search_terms, $page) // $search_terms is a serialized id of search terms stored in the session	{		$search_terms = $_SESSION[$search_terms];				$data = array();		if (isset($search_terms['featured']))			$this->db->select('SQL_CALC_FOUND_ROWS *')->from('mls_listings, custom_listings');		else			$this->db->select('SQL_CALC_FOUND_ROWS *')->from('mls_listings');		/* Determine what search terms to use based on the user input */		if (isset($search_terms['listing_agent_code']))			$this->db->where('listing_agent_code', $search_terms['listing_agent_code']);		if (isset($search_terms['listing_office_name']))			$this->db->where('listing_office_name', $search_terms['listing_office_name']);		if (isset($search_terms['city']))			$this->db->like('city', $search_terms['city']);		if (isset($search_terms['county']))			$this->db->like('county_name', $search_terms['county']);		if (isset($search_terms['zip']))			$this->db->like('zip_code', $search_terms['zip']);		if (isset($search_terms['street_number']))			$this->db->like('street_number', $search_terms['street_number']);		if (isset($search_terms['street_name']))			$this->db->like('street_name', $search_terms['street_name']);		if (isset($search_terms['mls_number']))			$this->db->like('mls_number', $search_terms['mls_number']);		if (isset($search_terms['subdivision_name']))			$this->db->like('subdivision_name', $search_terms['subdivision_name']);		if (isset($search_terms['condominium_name']))			$this->db->like('condominium_name', $search_terms['condominium_name']);		if (isset($search_terms['property_type']) && $search_terms['property_type'] != "Any")			$this->db->where('property_category', $search_terms['property_type']);		if (isset($search_terms['featured']))			$this->db->where('mls_listings.mls_number = custom_listings.mls_num')->where('custom_listings.featured', true);					$low_price = (!isset($search_terms['low_price'])) ? 0 : $search_terms['low_price'];		$high_price = (!isset($search_terms['high_price'])) ? 1000000000 : $search_terms['high_price'];		$this->db->where('list_price >=', $low_price);		$this->db->where('list_price <=', $high_price);				if (isset($search_terms['bedrooms']))			$this->db->where('number_of_bedrooms >=', $search_terms['bedrooms']);		if (isset($search_terms['bathrooms']))			$this->db->where('number_of_full_baths >=', $search_terms['bathrooms']);		if (isset($search_terms['square_feet']))			$this->db->where('building_square_feet >=', $search_terms['square_feet']);				// Declare the return arrays...		$data['houses'] = array();		$data['images'] = array();				$this->db->limit(10, $page);		$this->db->orderby('list_price');		$query = $this->db->get();				$found_rows = $this->db->query('SELECT FOUND_ROWS()');		foreach($found_rows->result_array() as $row)			$data['found_rows'] = $row['FOUND_ROWS()'];				$this->db->from('mls_photos');		$data['houses']['white'] = array();		$data['houses']['other'] = array();		foreach ($query->result() as $house)		{			if ($house->listing_office_name == "Century 21 White Real Estate")				$data['houses']['white'][] = $house;			else				$data['houses']['other'][] = $house;			$this->db->orlike('mls_number', $house->mls_number); // Add this mls number to the photo SQL search below						if (file_exists('images/mls_listings/' . $house->mls_number . '.jpg'))				$data['images'][$house->mls_number][] = array('link' => '/images/mls_listings/' . $house->mls_number . '.jpg', 'caption' => 'Primary Photo');		}				$this->db->orderby('picture_order');		$query2 = $this->db->get();				foreach ($query2->result() as $photo)			$data['images'][$photo->mls_number][] = $photo;				$temp = array();		foreach ($data['houses']['white'] as $house)			$temp[] = $house;		foreach ($data['houses']['other'] as $house)			$temp[] = $house;				$data['houses'] = array();		$data['houses'] = $temp;				return $data;	}