summaryrefslogtreecommitdiff
path: root/trunk/reprap/web/part-lister/models/country.php
blob: 5baad26583db3989fcbc8e461034a3ce44726c1a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?
	class Country extends Model
	{
		public function __construct($id = null)
		{
			parent::__construct($id, "countries");
		}
		
		public static function byCode($code)
		{
			$id = db()->get("
				SELECT id
				FROM countries
				WHERE code = '$code'
				LIMIT 1
			");
			
			return new Country($id);
		}
		
		public static function byGroup($group)
		{
			if ($group != 'all')
				$where = "WHERE group = '$group'";
				
			$sql = "
				SELECT id
				FROM countries
				$where
				ORDER BY name
			";
			
			return new Collection($sql, array('Country' => 'id'));
		}
	}
?>