Last active
August 29, 2015 14:19
-
-
Save drogers98/546e8fc807e5213b881c to your computer and use it in GitHub Desktop.
FMP PHP Commands
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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