forked from yodarunamok/fxphp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathObjectiveFX.php
60 lines (51 loc) · 1.37 KB
/
ObjectiveFX.php
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
<?php
/*******************************************************
* ObjectiveFX.php by Masayuki Nii ([email protected])
* Start from Jan 23, 2011
*
* How to use this, check following blog article:
* https://server.msyk.net/wiki/pages/f8C0Q7a6/
* *****************************************************
*/
define('FX_OBJECTIVE','I WILL USE IT!');
class ObjectiveFX {
var $result;
function __construct( $fxFullResult ) {
$this->result = $fxFullResult;
}
function getRecords() {
$recordArray = array();
foreach($this->result as $index=>$row) {
$recordArray[] = new ObjectiveFXRecord($row);
}
return $recordArray;
}
}
class ObjectiveFXRecord {
var $recordArray;
function __construct( $row ) {
foreach($row as $field=>$val) {
$fieldName = $field;
if (strpos($fieldName, '::') != false) {
$fieldName = str_replace('::', '__', $fieldName);
}
$this->recordArray[$fieldName] = $val;
}
}
function __get($name) {
if (!isset($this->recordArray[$name])) {
throw new ObjectiveFXException("The field name '{$name}' that you specified doesn't exist.");
}
if (is_array($this->recordArray[$name])) {
$portalArray = array();
foreach($this->recordArray[$name] as $ix=>$row) {
$portalArray[] = new ObjectiveFXRecord($row);
}
return $portalArray;
}
return $this->recordArray[$name];
}
}
class ObjectiveFXException extends Exception {
}
?>