summaryrefslogtreecommitdiff
path: root/framework/Data/SqlMap/Configuration/TParameterProperty.php
blob: d706a8369303dc1ec63f06f99a38fb7ea738fa8f (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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<?php
/**
 * TParameterPropert class file.
 *
 * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
 * @link https://github.com/pradosoft/prado
 * @copyright Copyright &copy; 2005-2016 The PRADO Group
 * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
 * @package System.Data.SqlMap.Configuration
 */

/**
 * TParameterProperty corresponds to the <property> tag and defines
 * one object property for the <parameterMap>
 *
 * The {@link NullValue setNullValue()} attribute can be set to any valid
 * value (based on property type). The {@link NullValue setNullValue()} attribute
 * is used to specify an inbound null value replacement. What this means is
 * that when the value is detected in the object property, a NULL will be written
 * to the database (the opposite behavior of an inbound null value replacement).
 * This allows you to use a magic null number in your application for types that
 * do not support null values (such as int, double, float). When these types of
 * properties contain a matching null value (for example, say, -9999), a NULL
 * will be written to the database instead of the value.
 *
 * @author Wei Zhuo <weizho[at]gmail[dot]com>
 * @package System.Data.SqlMap.Configuration
 * @since 3.1
 */
class TParameterProperty extends TComponent
{
	private $_typeHandler;
	private $_type;
	private $_column;
	private $_dbType;
	private $_property;
	private $_nullValue;

	/**
	 * @return string class name of a custom type handler.
	 */
	public function getTypeHandler()
	{
		return $this->_typeHandler;
	}

	/**
	 * @param string class name of a custom type handler.
	 */
	public function setTypeHandler($value)
	{
		$this->_typeHandler = $value;
	}

	/**
	 * @return string type of the parameter's property
	 */
	public function getType()
	{
		return $this->_type;
	}

	/**
	 * @param string type of the parameter's property
	 */
	public function setType($value)
	{
		$this->_type = $value;
	}

	/**
	 * @return string name of a parameter to be used in the SQL statement.
	 */
	public function getColumn()
	{
		return $this->_column;
	}

	/**
	 * @param string name of a parameter to be used in the SQL statement.
	 */
	public function setColumn($value)
	{
		$this->_column = $value;
	}

	/**
	 * @return string the database column type of the parameter to be set by this property.
	 */
	public function getDbType()
	{
		return $this->_dbType;
	}

	/**
	 * @param string the database column type of the parameter to be set by this property.
	 */
	public function setDbType($value)
	{
		$this->_dbType = $value;
	}

	/**
	 * @return string name of a property of the parameter object.
	 */
	public function getProperty()
	{
		return $this->_property;
	}

	/**
	 * @param string name of a property of the parameter object.
	 */
	public function setProperty($value)
	{
		$this->_property = $value;
	}

	/**
	 * @return mixed null value replacement
	 */
	public function getNullValue()
	{
		return $this->_nullValue;
	}

	/**
	 * The nullValue attribute is used to specify an outgoing null value replacement.
	 * @param mixed null value replacement.
	 */
	public function setNullValue($value)
	{
		$this->_nullValue = $value;
	}

	public function __sleep()
	{
		$exprops = array(); $cn = 'TParameterProperty';
		if ($this->_typeHandler===null) $exprops[] = "\0$cn\0_typeHandler";
		if ($this->_type===null) $exprops[] = "\0$cn\0_type";
		if ($this->_column===null) $exprops[] = "\0$cn\0_column";
		if ($this->_dbType===null) $exprops[] = "\0$cn\0_dbType";
		if ($this->_property===null) $exprops[] = "\0$cn\0_property";
		if ($this->_nullValue===null) $exprops[] = "\0$cn\0_nullValue";
		return array_diff(parent::__sleep(),$exprops);
	}
}