summaryrefslogtreecommitdiff
path: root/framework/DataAccess/SQLMap/Configuration/TDiscriminator.php
blob: 0ee34e3eabca0e60b13440b561c5807397178614 (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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php

class TDiscriminator extends TComponent
{
	private $_column='';
	private $_type='';
	private $_typeHandler=null;
	private $_dbType='';
	private $_columnIndex='';
	private $_nullValue='';
	private $_mapping='';
	private $_resultMaps=array();
	private $_subMaps=array();

	public function getColumn(){ return $this->_column; }
	public function setColumn($value){ $this->_column = $value; }

	public function getType(){ return $this->_type; }
	public function setType($value){ $this->_type = $value; }

	public function getTypeHandler(){ return $this->_typeHandler; }
	public function setTypeHandler($value){ $this->_typeHandler = $value; }

	public function getDbType(){ return $this->_dbType; }
	public function setDbType($value){ $this->_dbType = $value; }

	public function getColumnIndex(){ return $this->_columnIndex; }
	public function setColumnIndex($value){ $this->_columnIndex = $value; }

	public function getNullValue(){ return $this->_nullValue; }
	public function setNullValue($value){ $this->_nullValue = $value; }

	public function getMapping(){ return $this->_mapping; }

	public function getResultMaps(){ return $this->_resultMaps; }
	public function setResultMaps($value){ $this->_resultMaps = $value; }

	public function add($subMap)
	{ 
		$this->_subMaps[] = $subMap;
	}

	public function getSubMap($value)
	{ 
		if(isset($this->_resultMaps[$value]))
			return $this->_resultMaps[$value];
		else
			return null;
	}

	public function initMapping($sqlMap, $resultMap)
	{
		$this->_mapping = new TResultProperty;
		$this->_mapping->setColumn($this->getColumn());
		$this->_mapping->setColumnIndex($this->getColumnIndex());
		$this->_mapping->setType($this->getType());
		$this->_mapping->setTypeHandler($this->getTypeHandler());
		$this->_mapping->setDbType($this->getDbType());
		$this->_mapping->setNullValue($this->getNullValue());
		$this->_mapping->initialize($sqlMap, $resultMap);
	}

	public function initialize($sqlMap)
	{
		foreach($this->_subMaps as $subMap)
		{
			$this->_resultMaps[$subMap->getValue()] =
				$sqlMap->getResultMap($subMap->getResultMapping());
		}
	}
}


class TSubMap extends TComponent
{
	private $_value='';
	private $_resultMapping='';

	public function getValue(){ return $this->_value; }
	public function setValue($value){ $this->_value = $value; }

	public function getResultMapping(){ return $this->_resultMapping; }
	public function setResultMapping($value){ $this->_resultMapping = $value; }
}

?>