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); } } ?>