summaryrefslogtreecommitdiff
path: root/framework/DataAccess/SQLMap/Configuration/TResultMap.php
blob: 0f09a1ba9c5642eea23006943f181deaec4029ad (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
61
62
63
<?php

class TResultMap extends TComponent
{
	private $_ID='';
	private $_className='';
	private $_columns='';
	private $_extendMap='';
	private $_groupBy='';
	private $_discriminator=null;

	public function __construct()
	{
		$this->_columns = new TMap;
	}

	public function getID(){ return $this->_ID; }
	public function setID($value){ $this->_ID = $value; }

	public function getClass(){ return $this->_className; }
	public function setClass($value){ $this->_className = $value; }

	public function getColumns(){ return $this->_columns; }
	public function setColumns($value){ $this->_columns = $value; }

	public function getExtends(){ return $this->_extendMap; }
	public function setExtends($value){ $this->_extendMap = $value; }

	public function getGroupBy(){ return $this->_groupBy; }
	public function setGroupBy($value){ $this->_groupBy = $value; }

	public function getDiscriminator(){ return $this->_discriminator; }
	public function setDiscriminator($value){ $this->_discriminator = $value; }

	public function addResultProperty(TResultProperty $property)
	{
		$this->_columns->add($property->getProperty(), $property);
	}
	
	public function createInstanceOfResult()
	{
		return TTypeHandlerFactory::createInstanceOf($this->getClass());
	}

	public function resolveSubMap($row)
	{
		$subMap = $this;
		if(!is_null($disc = $this->getDiscriminator()))
		{
			$mapping = $disc->getMapping();
			$dataValue = $mapping->getDatabaseValue($row);
			$subMap = $disc->getSubMap((string)$dataValue);
		
			if(is_null($subMap))
				$subMap = $this;
			else if($subMap !== $this)
				$subMap = $subMap->resolveSubMap($row);
		}
		return $subMap;
	}
}

?>