Skip to content

Instantly share code, notes, and snippets.

@drogers98
Last active August 29, 2015 14:19
Show Gist options
  • Save drogers98/546e8fc807e5213b881c to your computer and use it in GitHub Desktop.
Save drogers98/546e8fc807e5213b881c to your computer and use it in GitHub Desktop.
FMP PHP Commands
//create record
$rec = $fm->createRecord('layout_name', '$data_array');
$result = $rec->commit();
//new add command
$newAdd = $fm->newAddCommand('layout_name', $data_array);
$result = $newAdd->execute();
//Second and main difference is what they return to $result variable. The 'createRecord()' statement returns an integer value to know the status of record creation process(whether succeed or failed). But the 'newAddCommand()' returns a bunch of information for the new created record along with record id.
//Create an Add request
$addrequest = $fm->newAddCommand('layout_name', 'field_array');
//Validate all fields
$result = $addrequest->validate();
if(FileMaker::isError($result)){
$validation_error = $result->getErrors();
foreach ($validation_error as $err) {
$field = $err[0];
echo 'Field Name: ' . $field->getName(). "\n";
echo 'Error Code: ' . $err[1] . "\n";
echo 'Value: ' . $err[2] . "\n";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment