|
19 | 19 | // Instantiate the class FMDataAPI with database name, user name, password and host. |
20 | 20 | // Although the port number and protocol can be set in parameters of constructor, |
21 | 21 | // these parameters can be omitted with default values. |
22 | | - $fmdb = new FMDataAPI("TestDB", "web", "password", "localhost"); |
| 22 | + $fmdb = new FMDataAPI("TestDB", "web", "password", "10.211.56.2"); |
23 | 23 |
|
24 | 24 | //============================== |
25 | 25 | //$fmdb = new FMDataAPI("TestDB", "web", "password", "localserver"); |
|
72 | 72 | echo htmlspecialchars("Error Code: {$fmdb->errorCode()}", ENT_QUOTES, "UTF-8") . "<hr>"; |
73 | 73 | echo htmlspecialchars("Error Message: {$fmdb->errorMessage()}", ENT_QUOTES, "UTF-8") . "<hr>"; |
74 | 74 |
|
75 | | - // If the query is succeed, the following information can be detected. |
| 75 | + // If the query is succeeded, the following information can be detected. |
76 | 76 | echo htmlspecialchars("Target Table: {$fmdb->getTargetTable()}", ENT_QUOTES, "UTF-8") . "<hr>"; |
77 | 77 | echo htmlspecialchars("Total Count: {$fmdb->getTotalCount()}", ENT_QUOTES, "UTF-8") . "<hr>"; |
78 | 78 | echo htmlspecialchars("Found Count: {$fmdb->getFoundCount()}", ENT_QUOTES, "UTF-8") . "<hr>"; |
79 | 79 | echo htmlspecialchars("Returned Count: {$fmdb->getReturnedCount()}", ENT_QUOTES, "UTF-8") . "<hr>"; |
80 | 80 |
|
81 | 81 | // The FileMakerRelation class implements the Iterator interface and it can repeat with 'foreach.' |
82 | 82 | // The $record also refers a FileMakerRelation object but it is for single record. |
83 | | - // This layout has fields as like 'id', 'name', 'mail' and so on, and the field name can be handle |
84 | | - // as a property name of the the record referring with $record. |
| 83 | + // This layout has fields as like 'id', 'name', 'mail' and so on, and the field name can be handled |
| 84 | + // as a property name of the record referring with $record. |
85 | 85 | if (!is_null($result)) { |
86 | | - // If the query is succeed, the following information can be detected. |
| 86 | + // If the query is succeeded, the following information can be detected. |
87 | 87 | echo htmlspecialchars("Target Table: {$result->getTargetTable()}", ENT_QUOTES, "UTF-8") . "<hr>"; |
88 | 88 | echo htmlspecialchars("Total Count: {$result->getTotalCount()}", ENT_QUOTES, "UTF-8") . "<hr>"; |
89 | 89 | echo htmlspecialchars("Found Count: {$result->getFoundCount()}", ENT_QUOTES, "UTF-8") . "<hr>"; |
|
101 | 101 | // A portal name property returns records of portal as FileMakerRelation object. |
102 | 102 | $contacts = $record->Contact; |
103 | 103 |
|
104 | | - // If the query is succeed, the following information can be detected. |
| 104 | + // If the query is succeeded, the following information can be detected. |
105 | 105 | echo htmlspecialchars("Target Table: {$contacts->getTargetTable()}", ENT_QUOTES, "UTF-8") . "<hr>"; |
106 | 106 | echo htmlspecialchars("Total Count: {$contacts->getTotalCount()}", ENT_QUOTES, "UTF-8") . "<hr>"; |
107 | 107 | echo htmlspecialchars("Found Count: {$contacts->getFoundCount()}", ENT_QUOTES, "UTF-8") . "<hr>"; |
|
122 | 122 | echo "<hr>"; |
123 | 123 | } |
124 | 124 |
|
| 125 | + |
| 126 | + echo "<h3>toArray() results</h3>"; |
| 127 | + echo "<h4>[query_result]->toArray()</h4>"; |
| 128 | + var_export($result->toArray()); |
| 129 | + |
| 130 | + foreach ($result as $record) { |
| 131 | + echo "<hr>"; |
| 132 | + echo "<h4>[each_record]->toArray()</h4>"; |
| 133 | + var_export($record->toArray()); |
| 134 | + foreach ($result->getPortalNames() as $portalName) { |
| 135 | + echo "<h4>[portal]->toArray()</h4>"; |
| 136 | + var_export($record->$portalName->toArray()); |
| 137 | + foreach ($record->$portalName as $portalRecord) { |
| 138 | + echo "<h4>[each_portal_record]->toArray()</h4>"; |
| 139 | + var_export($portalRecord->toArray()); |
| 140 | + } |
| 141 | + } |
| 142 | + } |
| 143 | + |
125 | 144 | // Move to pointer to the first record. |
126 | 145 | $result->rewind(); |
127 | 146 |
|
|
0 commit comments