Note: When working with FX.php, users can choose to use either the original syntax, or a newer, streamlined syntax. Because most users of FX.php will be more familiar with the older syntax, and to keep the examples as consistent as possible, the FX.php examples below use the original syntax.
<?php
require_once ('FX/FX.php');
$request = new FX('127.0.0.1', '80', 'FMPro7');
$request->SetDBData('TimeTracker.fp7', 'associate_layout');
$request->SetDBUserPass('esmith', 'f!r3crack3r');
$request->SetLogicalOR();
$request->AddDBParam('Account Name', 'M');
$request->AddDBParam('Account Name', 'T');
$request->AddSortParam('Account Name');
$result = $request->FMFind();
$records = $result['data'];
echo '<table border="1">';
echo '<tr>';
echo '<th>Status</th>';
echo '<th>Type</th>';
echo '<th>Account Name</th>';
echo '</tr>';
foreach($records as $record) {
if ($record['Status'][0] != 'Active') {
echo '<tr>';
echo '<td>'.$record['Status'][0].'</td>';
echo '<td>'.$record['Type'][0].'</td>';
echo '<td>'.$record['Account Name'][0].'</td>';
echo '</tr>';
}
}
echo '</table>';
?>
<?php
require_once ('Filemaker/Filemaker.php');
$fm = new FileMaker('TimeTracker.fp7', '127.0.0.1', 'esmith', 'f!r3crack3r');
$request = $fm->newFindRequest('associate_layout');
$request->addFindCriterion('Account Name', 'M');
$request2 = $fm->newFindRequest('associate_layout');
$request2->addFindCriterion('Account Name', 'T');
$request3 = $fm->newFindRequest('associate_layout');
$request3->addFindCriterion('Status', 'Active');
$request3->setOmit(TRUE);
$compoundFind = $fm->newCompoundFindCommand('associate_layout');
$compoundFind->add(1, $request);
$compoundFind->add(2, $request2);
$compoundFind->add(3, $request3);
$compoundFind->addSortRule('Account Name', 1, FILEMAKER_SORT_ASCEND);
$result = $compoundFind->execute();
$records = $result->getRecords();
echo '<table border="1">';
echo '<tr>';
echo '<th>Status</th>';
echo '<th>Type</th>';
echo '<th>Account Name</th>';
echo '</tr>';
foreach ($records as $record) {
echo '<tr>';
echo '<td>'.$record->getField('Status').'</td>';
echo '<td>'.$record->getField('Type').'</td>';
echo '<td>'.$record->getField('Account Name').'</td>';
echo '</tr>';
}
echo '</table>';
?>
<?php
require_once ('FX/FX.php');
$newRecordRequest = new FX('127.0.0.1', '80', 'FMPro7');
$newRecordRequest->SetDBData('TimeTracker.fp7', 'associate_layout');
$newRecordRequest->SetDBUserPass('esmith', 'f!r3crack3r');
$newRecordRequest->AddDBParam('Account Name', 'twilliams');
$newRecordRequest->AddDBParam('Status', 'Active');
$newRecordRequest->AddDBParam('Type', 'Employee');
$result = $newRecordRequest->FMNew();
?>
<?php
require_once ('Filemaker/Filemaker.php');
$fm = new FileMaker('TimeTracker.fp7', '127.0.0.1', 'esmith', 'f!r3crack3r');
$record = $fm->createRecord('associate_layout');
$record->setField('Account Name', 'twilliams');
$record->setField('Status', 'Active');
$record->setField('Type', 'Employee');
$result = $record->commit();
?>
<?php
require_once ('FX/FX.php');
$request = new FX('127.0.0.1', '80', 'FMPro7');
$request->SetDBData('TimeTracker.fp7', 'associate_layout');
$request->SetDBUserPass('esmith', 'f!r3crack3r');
$request->AddDBParam('-recid', '136');
$result = $request->FMDelete();
?>
<?php
require_once ('Filemaker/Filemaker.php');
$fm = new FileMaker('TimeTracker.fp7', '127.0.0.1', 'esmith', 'f!r3crack3r');
$deleteRecord = $fm->newDeleteCommand('associate_layout', '140');
$result = $deleteRecord->execute();
?>
<?php
// Find associate records
require_once ('FX/FX.php');
$request = new FX('127.0.0.1', '80', 'FMPro7');
$request->SetDBData('TimeTracker.fp7', 'associate_layout');
$request->SetDBUserPass('esmith', 'f!r3crack3r');
$request->AddDBParam('Status', 'Active');
$result = $request->FMFind();
$records = $result['data'];
// Loop through the associate records
foreach ($records as $record) {
// Display the current associate record
echo '<div>';
echo '<table border="1">';
echo '<tr><th>Account Name</th><td>'.$record['Account Name'][0].'</td></tr>';
echo '<tr><th>Status</th><td>'.$record['Status'][0].'</td></tr>';
echo '<tr><th>Type</th><td>'.$record['Type'][0].'</td></tr>';
echo '</table>';
// Display the time records in a separate table
echo '<table border="1">';
echo '<tr>';
echo '<th>Date</th>';
echo '<th>Duration</th>';
echo '<th>Description</th>';
echo '</tr>';
foreach ($record['Time::Date Performed'] as $key => $val) {
echo '<tr>';
echo '<td>'.$record['Time::Date Performed'][$key].'</td>';
echo '<td>'.$record['Time::Hours Actual'][$key].'</td>';
echo '<td>'.$record['Time::Description'][$key].'</td>';
echo '</tr>';
}
echo '</table>';
echo '</div>';
}
?>
<?php
// Find associate records
require_once ('Filemaker/Filemaker.php');
$fm = new FileMaker('TimeTracker.fp7', '127.0.0.1', 'esmith', 'f!r3crack3r');
$request = $fm->newFindCommand('associate_layout');
$request->addFindCriterion('Status', 'Active');
$result = $request->execute();
$records = $result->getRecords();
// Loop through the associate records
foreach ($records as $record) {
// Display the current associate record
echo '<div>';
echo '<table border="1">';
echo '<tr><th>Account Name</th><td>'.$record->getField('Account Name').'</td></tr>';
echo '<tr><th>Status</th><td>'.$record->getField('Status').'</td></tr>';
echo '<tr><th>Type</th><td>'.$record->getField('Type').'</td></tr>';
echo '</table>';
// Get the time records related to this associate
$timeRecords = $record->getRelatedSet('Time');
// Display the time records in a separate table
echo '<table border="1">';
echo '<tr>';
echo '<th>Date</th>';
echo '<th>Duration</th>';
echo '<th>Description</th>';
echo '</tr>';
foreach ($timeRecords as $timeRecord) {
echo '<tr>';
echo '<td>'.$timeRecord->getField('Time::Date Performed').'</td>';
echo '<td>'.$timeRecord->getField('Time::Hours Actual').'</td>';
echo '<td>'.$timeRecord->getField('Time::Description').'</td>';
echo '</tr>';
}
echo '</table>';
echo '</div>';
}
?>
<?php
require_once ('FX/FX.php');
$request = new FX('127.0.0.1', '80', 'FMPro7');
$request->SetDBData('TimeTracker.fp7', 'associate_layout');
$request->SetDBUserPass('esmith', 'f!r3crack3r');
$request->AddDBParam('-recid', '136');
$request->AddDBParam('Account Name', 'ttester');
$request->AddDBParam('Status', 'Inactive');
$request->AddDBParam('Type', 'Contractor');
$result = $request->FMEdit();
?>
<?php
require_once ('Filemaker/Filemaker.php');
$fm = new FileMaker('TimeTracker.fp7', '127.0.0.1', 'esmith', 'f!r3crack3r');
$editRecord = $fm->newEditCommand('associate_layout', '140');
$editRecord->setField('Account Name', 'twilliams');
$editRecord->setField('Status', 'Active');
$editRecord->setField('Type', 'Employee');
$result = $editRecord->execute();
?>
<?php
require_once ('FX/FX.php');
$request = new FX('127.0.0.1', '80', 'FMPro7');
$request->SetDBData('TimeTracker.fp7', 'associate_layout');
$request->SetDBUserPass('esmith', 'f!r3crack3r');
$request->AddDBParam('Type', 'Administrator');
$result = $request->FMFind();
$records = $result['data'];
foreach($records as $keys => $record) {
list($recid, $modid) = explode('.', $keys);
$request = new FX('127.0.0.1', '80', 'FMPro7');
$request->SetDBData('TimeTracker.fp7', 'associate_layout');
$request->SetDBUserPass('esmith', 'f!r3crack3r');
$request->AddDBParam('-recid', $recid);
$request->AddDBParam('Type', 'Admin');
$result = $request->FMEdit();
}
?>
<?php
require_once ('Filemaker/Filemaker.php');
$fm = new FileMaker('TimeTracker.fp7', '127.0.0.1', 'esmith', 'f!r3crack3r');
$request = $fm->newFindCommand('associate_layout');
$request->addFindCriterion('Type', 'Admin');
$result = $request->execute();
$records = $result->getRecords();
foreach ($records as $record) {
$record->setField('Type', 'Administrator');
$record->commit();
}
?>
<?php
require_once ('FX/FX.php');
$request = new FX('127.0.0.1', '80', 'FMPro7');
$request->SetDBData('TimeTracker.fp7', 'associate_layout');
$request->SetDBUserPass('esmith', 'f!r3crack3r');
$request->AddDBParam('ID Associate', '120..');
$result = $request->FMFind();
$records = $result['data'];
echo '<table border="1">';
echo '<tr>';
echo '<th>Status</th>';
echo '<th>Type</th>';
echo '<th>Account Name</th>';
echo '</tr>';
foreach($records as $record) {
echo '<tr>';
echo '<td>'.$record['Status'][0].'</td>';
echo '<td>'.$record['Type'][0].'</td>';
echo '<td>'.$record['Account Name'][0].'</td>';
echo '</tr>';
}
echo '</table>';
?>
<?php
require_once ('Filemaker/Filemaker.php');
$fm = new FileMaker('TimeTracker.fp7', '127.0.0.1', 'esmith', 'f!r3crack3r');
$request = $fm->newFindCommand('associate_layout');
$request->addFindCriterion('ID Associate', '120...');
$result = $request->execute();
$records = $result->getRecords();
echo '<table border="1">';
echo '<tr>';
echo '<th>Status</th>';
echo '<th>Type</th>';
echo '<th>Account Name</th>';
echo '</tr>';
foreach ($records as $record) {
echo '<tr>';
echo '<td>'.$record->getField('Status').'</td>';
echo '<td>'.$record->getField('Type').'</td>';
echo '<td>'.$record->getField('Account Name').'</td>';
echo '</tr>';
}
echo '</table>';
?>
<?php
require_once ('FX/FX.php');
$request = new FX('127.0.0.1', '80', 'FMPro7');
$request->SetDBData('TimeTracker.fp7', 'associate_layout');
$request->SetDBUserPass('esmith', 'f!r3crack3r');
$request->AddSortParam('Status');
$request->AddSortParam('Type');
$request->AddSortParam('Account Name');
$result = $request->FMFindAll();
$records = $result['data'];
echo '<table border="1">';
echo '<tr>';
echo '<th>Status</th>';
echo '<th>Type</th>';
echo '<th>Account Name</th>';
echo '</tr>';
foreach($records as $record) {
echo '<tr>';
echo '<td>'.$record['Status'][0].'</td>';
echo '<td>'.$record['Type'][0].'</td>';
echo '<td>'.$record['Account Name'][0].'</td>';
echo '</tr>';
}
echo '</table>';
?>
<?php
require_once ('Filemaker/Filemaker.php');
$fm = new FileMaker('TimeTracker.fp7', '127.0.0.1', 'esmith', 'f!r3crack3r');
$request = $fm->newFindAllCommand('associate_layout');
$request->addSortRule('Status', 1);
$request->addSortRule('Type', 2);
$request->addSortRule('Account Name', 3);
$result = $request->execute();
$records = $result->getRecords();
echo '<table border="1">';
echo '<tr>';
echo '<th>Status</th>';
echo '<th>Type</th>';
echo '<th>Account Name</th>';
echo '</tr>';
foreach ($records as $record) {
echo '<tr>';
echo '<td>' . $record->getField('Status') . '</td>';
echo '<td>' . $record->getField('Type') . '</td>';
echo '<td>' . $record->getField('Account Name') . '</td>';
echo "</tr>";
}
echo '</table>';
?>
<?php
require_once ('FX/FX.php');
$request = new FX('127.0.0.1', '80', 'FMPro7');
$request->SetDBData('TimeTracker.fp7', 'associate_layout');
$request->SetDBUserPass('esmith', 'f!r3crack3r');
$request->SetLogicalOR();
$request->AddDBParam('Type', 'Admin');
$request->AddDBParam('Type', 'Intern');
$result = $request->FMFind();
$records = $result['data'];
echo '<table border="1">';
echo '<tr>';
echo '<th>Status</th>';
echo '<th>Type</th>';
echo '<th>Account Name</th>';
echo '</tr>';
foreach($records as $record) {
echo '<tr>';
echo '<td>'.$record['Status'][0].'</td>';
echo '<td>'.$record['Type'][0].'</td>';
echo '<td>'.$record['Account Name'][0].'</td>';
echo '</tr>';
}
echo '</table>';
?>
<?php
require_once ('Filemaker/Filemaker.php');
$fm = new FileMaker('TimeTracker.fp7', '127.0.0.1', 'esmith', 'f!r3crack3r');
$request = $fm->newFindCommand('associate_layout');
$request->setLogicalOperator(FILEMAKER_FIND_OR);
$request->addFindCriterion('Type', 'Admin');
$request->addFindCriterion('Type', 'Intern');
$result = $request->execute();
$records = $result->getRecords();
echo '<table border="1">';
echo '<tr>';
echo '<th>Status</th>';
echo '<th>Type</th>';
echo '<th>Account Name</th>';
echo '</tr>';
foreach ($records as $record) {
echo '<tr>';
echo '<td>'.$record->getField('Status').'</td>';
echo '<td>'.$record->getField('Type').'</td>';
echo '<td>'.$record->getField('Account Name').'</td>';
echo "</tr>";
}
echo '</table>';
?>
Potential Gotcha: Because FX.php sends POST requests to FileMaker by default, and manual connections generally use GET, the connection performed via a manual connection for debugging is not precisely identical to the connection performed by FX.php.
Note: The latest release of FX.php includes the FX Fuzzy Debugger class which can be used as a debugging aid with either tool.
<?php
// this can be toggled to true for additional error checking
define('DEBUG', FALSE);
require_once ('FX/FX.php');
$request = new FX('127.0.0.1', '80', 'FMPro7');
$request->SetDBData('TimeTracker.fp7', 'associate_layout');
$request->SetDBUserPass('esmith', 'f!r3crack3r');
$request->AddSortParam('Status');
$request->AddSortParam('Type');
$request->AddSortParam('Account Name');
$result = $request->FMFindAll();
echo '<table border="1">';
echo '<tr>';
echo '<th>Status</th>';
echo '<th>Type</th>';
echo '<th>Account Name</th>';
echo '</tr>';
if (FX::isError($result)) {
echo '<tr>';
echo '<td colspan="3">A System Error Occured</td>';
echo '</tr>';
} elseif ($result['foundCount'] < 1) {
echo '<tr>';
echo '<td colspan="3">No Records Found (Error Code: '.$result['errorCode'].')</td>';
echo '</tr>';
} else {
$records = $result['data'];
foreach($records as $record) {
echo '<tr>';
echo '<td>'.$record['Status'][0].'</td>';
echo '<td>'.$record['Type'][0].'</td>';
echo '<td>'.$record['Account Name'][0].'</td>';
echo '</tr>';
}
}
echo '</table>';
?>
<?php
require_once ('Filemaker/Filemaker.php');
$fm = new FileMaker('TimeTracker.fp7', '127.0.0.1', 'esmith', 'f!r3crack3r');
$request = $fm->newFindAllCommand('associate_layout');
$request->addSortRule('Status', 1);
$request->addSortRule('Type', 2);
$request->addSortRule('Account Name', 3);
$result = $request->execute();
echo '<table border="1">';
echo '<tr>';
echo '<th>Status</th>';
echo '<th>Type</th>';
echo '<th>Account Name</th>';
echo '</tr>';
if (FileMaker::isError($result)) {
if (! isset($result->code) || strlen(trim($result->code)) < 1) {
echo '<tr>';
echo '<td colspan="3">A System Error Occured</td>';
echo '</tr>';
} else {
echo '<tr>';
echo '<td colspan="3">No Records Found (Error Code: '.$result->code.')</td>';
echo '</tr>';
}
} else {
$records = $result->getRecords();
foreach ($records as $record) {
echo '<tr>';
echo '<td>' . $record->getField('Status') . '</td>';
echo '<td>' . $record->getField('Type') . '</td>';
echo '<td>' . $record->getField('Account Name') . '</td>';
echo "</tr>";
}
}
echo '</table>';
?>
Note: Wrapper classes can be created around either tool to add additional, custom functionality.
Potential Gotcha: If you do use the FileMaker API for PHP Installer, and then subsequently run the Uninstaller, you may need to manually edit your web server software's configuration. In testing on Apache running on Mac OS X, this meant that Apache would not start until httpd.conf had been manually modified.
Potential Gotcha: When doing the manual install for either tool, be sure that the privileges for all related files allow all users read (and possibly execute) access. At the very least, give this level of access to the user under which the server process runs. For security reasons, web server processes run under special low access accounts -- almost certainly not the account used to install the software.
Note: On Mac OS X, cURL is present by default, and cURL is installed by the FileMaker installer, if used.
Potential Gotcha: As is always the case when working with web-based solutions, firewalls and server addressing (among other things) can add complexity when installing, configuring, and/or testing with either tool.