<?php

class PopularDestinations {

	public static function get($db, $country, $city, $limit=10) {
		$city_id = (int)$city;
		$country_code = pg_escape_string($country);

		$q = "SELECT a.id AS attraction_id,a.attraction,a.active,a.address_id,a.city_id,b.* ";
		$q.= " FROM tourist_attraction a, address b ";
		$q.= " WHERE b.id=a.address_id AND b.country='SG' AND a.city_id=1 AND a.active='t' ";
		$q.= " ORDER BY a.attraction";

		$r = pg_query($db, $q);
		if ($r && pg_num_rows($r)) {
			$result = [];
			while ($f=pg_fetch_assoc($r)) {
				$result[] = $f;
			}
			return [$result, NULL];
		}
		return [NULL,pg_last_error()];
	}

}
// vi:ts=2

