1
|
|
|
<?php |
2
|
|
|
require_once(dirname(__FILE__) . '/../fwolflib.php'); |
3
|
|
|
|
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Return value class |
7
|
|
|
* |
8
|
|
|
* @deprecated Use Fwlib\Base\ReturnValue |
9
|
|
|
* @package fwolflib |
10
|
|
|
* @subpackage class |
11
|
|
|
* @copyright Copyright © 2013, Fwolf |
12
|
|
|
* @author Fwolf <[email protected]> |
13
|
|
|
* @since 2013-05-03 |
14
|
|
|
*/ |
15
|
|
|
class Rv extends Fwolflib { |
|
|
|
|
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Return value info |
19
|
|
|
* |
20
|
|
|
* array( |
21
|
|
|
* code, // Normally 0=no error, c>0=info, c<0=error occur |
22
|
|
|
* msg, |
23
|
|
|
* data, |
24
|
|
|
* ) |
25
|
|
|
* |
26
|
|
|
* @var array |
27
|
|
|
*/ |
28
|
|
|
public $aInfo = array( |
29
|
|
|
'code' => 0, |
30
|
|
|
'msg' => null, |
31
|
|
|
'data' => null, |
32
|
|
|
); |
33
|
|
|
|
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* constructor |
37
|
|
|
* |
38
|
|
|
* @param int $i_code |
39
|
|
|
* @param string $s_msg |
40
|
|
|
* @param mixed $m_data |
41
|
|
|
*/ |
42
|
|
|
public function __construct ($i_code = 0, $s_msg = null, $m_data = null) { |
43
|
|
|
parent::__construct(); |
44
|
|
|
|
45
|
|
|
$this->aInfo = array( |
46
|
|
|
'code' => $i_code, |
47
|
|
|
'msg' => $s_msg, |
48
|
|
|
'data' => $m_data, |
49
|
|
|
); |
50
|
|
|
} // end of func __construct |
51
|
|
|
|
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Get/set code |
55
|
|
|
* |
56
|
|
|
* @param int $i_code |
57
|
|
|
* @param boolean $b_force Force do value assign ignore null |
58
|
|
|
* @return int |
59
|
|
|
*/ |
60
|
|
|
public function Code ($i_code = null, $b_force = false) { |
61
|
|
|
return $this->GetSetInfo('code', $i_code, $b_force); |
62
|
|
|
} // end of func Code |
63
|
|
|
|
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Get/set data |
67
|
|
|
* |
68
|
|
|
* @param mixed $m_data |
69
|
|
|
* @param boolean $b_force Force do value assign ignore null |
70
|
|
|
* @return mixed |
71
|
|
|
*/ |
72
|
|
|
public function Data ($m_data = null, $b_force = false) { |
73
|
|
|
return $this->GetSetInfo('data', $m_data, $b_force); |
74
|
|
|
} // end of func Data |
75
|
|
|
|
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* Is result means error ? |
79
|
|
|
* |
80
|
|
|
* @return boolean |
81
|
|
|
*/ |
82
|
|
|
public function Error () { |
83
|
|
|
return ($this->aInfo['code'] < 0); |
84
|
|
|
} // end of func Error |
85
|
|
|
|
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* Get error msg |
89
|
|
|
* |
90
|
|
|
* @return string |
91
|
|
|
*/ |
92
|
|
|
public function ErrorMsg () { |
93
|
|
|
return $this->aInfo['msg']; |
94
|
|
|
} // end of func ErrorMsg |
95
|
|
|
|
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* Get error no |
99
|
|
|
* |
100
|
|
|
* Do NOT do if error check. |
101
|
|
|
* |
102
|
|
|
* @return int |
103
|
|
|
*/ |
104
|
|
|
public function ErrorNo () { |
105
|
|
|
return $this->aInfo['code']; |
106
|
|
|
} // end of func ErrorNo |
107
|
|
|
|
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* Convert to array |
111
|
|
|
* |
112
|
|
|
* @return array |
113
|
|
|
*/ |
114
|
|
|
public function GetArray () { |
115
|
|
|
return $this->aInfo; |
116
|
|
|
} // end of func GetArray |
117
|
|
|
|
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* Get/set info array |
121
|
|
|
* |
122
|
|
|
* @param string $idx Should be one of code/msg/data, but no check |
123
|
|
|
* @param mixed $val |
124
|
|
|
* @param boolean $b_force Force do value assign ignore null |
125
|
|
|
* @return mixed |
126
|
|
|
*/ |
127
|
|
|
protected function GetSetInfo ($idx, $val = null, $b_force = false) { |
128
|
|
|
if (!is_null($val) || ((is_null($val)) && $b_force)) |
129
|
|
|
$this->aInfo[$idx] = $val; |
130
|
|
|
|
131
|
|
|
return $this->aInfo[$idx]; |
132
|
|
|
} // end of func GetSetInfo |
133
|
|
|
|
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* Get/set msg |
137
|
|
|
* |
138
|
|
|
* @param string $s_msg |
139
|
|
|
* @param boolean $b_force Force do value assign ignore null |
140
|
|
|
* @return string |
141
|
|
|
*/ |
142
|
|
|
public function Msg ($s_msg = null, $b_force = false) { |
143
|
|
|
return $this->GetSetInfo('msg', $s_msg, $b_force); |
144
|
|
|
} // end of func Msg |
145
|
|
|
|
146
|
|
|
|
147
|
|
|
} // end of class Rv |
148
|
|
|
?> |
|
|
|
|
149
|
|
|
|
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.