summaryrefslogtreecommitdiff
path: root/demos/northwind-db/protected/database/Territory.php
blob: 96006bb1e61fd1ced40e3c2e7d22961cb445bf42 (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
/**
 * Auto generated by prado-cli.php on 2007-05-01 05:33:28.
 */
class Territory extends TActiveRecord
{
	const TABLE='Territories';

	public $TerritoryID;
	public $TerritoryDescription;
	public $RegionID;

	private $_region;
	private $_employees;

	public static $RELATIONS = array
	(
		'Region' => array(self::BELONGS_TO, 'Region'),
		'Employees' => array(self::HAS_MANY, 'Employee', 'EmployeeTerritories')
	);

	/**
	 * @return Region
	 */
	public function getRegion()
	{
		//lazy load the region
		if($this->_region===null)
			$this->_region = Region::finder()->findByPk($this->RegionID);
		return $this->_region;
	}

	public function setRegion($value)
	{
		$this->_region=$value;
	}

	/**
	 * @return Employee[]
	 */
	public function getEmployees()
	{
		//lazy load
		if($this->_employees==null)
			$this->setEmployees($this->withEmployees()->findByPk($this->TerritoryID)->getEmployees());
		return $this->_employees;
	}

	public function setEmployees($value)
	{
		//ensure TList
		$this->_employees = $value instanceof TList ? $value : new TList($value);
	}

	public static function finder($className=__CLASS__)
	{
		return parent::finder($className);
	}
}
?>