fmPDA Version 1 (FileMaker Server 18+)
fmPDA Constructor

                     __construct($database, $host, $username, $password, $options = array())

                        Constructor for fmPDA.

                        Parameters:
                           (string)  $database         The name of the database (do NOT include the .fmpNN extension)
                           (string)  $host             The host name typically in the format of https://HOSTNAME
                           (string)  $username         The user name of the account to authenticate with
                           (string)  $password         The password of the account to authenticate with
                           (array)   $options          Optional parameters
                                                           ['version'] Version of the API to use (1, 2, etc. or 'Latest')

                                                           ['authentication'] set to 'oauth' for oauth authentication
                                                           ['oauthID'] oauthID
                                                           ['oauthIdentifier'] oauth identifier

                                                           ['sources'] => array(                      External database authentication
                                                                            array(
                                                                              'database'  => '',      // do NOT include .fmpNN
                                                                              'username'  => '',
                                                                              'password'  => ''
                                                                            )
                                                                          )

                        Returns:
                           The newly created object.

                        Example:
                           $fm = new fmPDA($database, $host, $username, $password);
                  
fmPDA::listDatabases($userName = '', $password = '')

                     function listDatabases()

                        Retrieve a list of hosted FileMaker databases that the given credentails can see.

                        Parameters:
                           (string)  $username         The user name of the account to authenticate with
                                                       If empty, the username passed to the constructor will be used.
                           (string)  $password         The password of the account to authenticate with
                                                       If empty, the password passed to the constructor will be used.

                        Returns:
                           An JSON-decoded associative array of the API result. Typically:
                              ['response'] A list of databases
                              ['messages'] Array of code/message pairs

                        Example:
                           $fm = new fmPDA($database, $host, $username, $password);
                           $apiResult = $fm->listDatabases()
                           if (! $fm->getIsError($apiResult)) {
                              ...
                           }
                  
Return a list of databases
fmPDA::listLayouts()

                     function listLayouts()

                        Retrieves a list of layouts for the database

                        Parameters:
                           None

                        Returns:
                           An JSON-decoded associative array of the API result. Typically:
                              ['response'] A list of layouts in the database
                              ['messages'] Array of code/message pairs

                        Example:
                           $fm = new fmPDA($database, $host, $username, $password);
                           $apiResult = $fm->listLayouts()
                           if (! $fm->getIsError($apiResult)) {
                              ...
                           }
                  
Return a list of layouts in the database
fmPDA::listScripts()

                     function listScripts()

                        Retrieves a list of scripts for the database

                        Parameters:
                           None

                        Returns:
                           An JSON-decoded associative array of the API result. Typically:
                              ['response'] A list of scripts in the database
                              ['messages'] Array of code/message pairs

                        Example:
                           $fm = new fmPDA($database, $host, $username, $password);
                           $apiResult = $fm->listScripts()
                           if (! $fm->getIsError($apiResult)) {
                              ...
                           }
                  
Return a list of scripts in the database
fmPDA::getRecordById()

                     function getRecordById($layout, $recordID = '')

                        Get the record specified by $recordID. If you omit the recordID, the first record in the table is returned.

                        Parameters:
                           (string)  $layout           The name of the layout
                           (integer) $recordID         The recordID of the record to retrieve

                        Returns:
                           An fmRecord or fmError object

                        Example:
                           $fm = new fmPDA($database, $host, $username, $password);
                           $result = $fm->getRecordById('Web_Project', 1);
                           if (! $fm->getIsError($result)) {
                              ...
                           }
                  
Get 2 records by ID, second one will fail because it doesn't exist
fmPDA::newFindAllCommand()

                     function newFindAllCommand($layoutName)

                        Create a new find all object.

                        Parameters:
                           (string)  $layoutName           The name of the layout

                        Returns:
                           A fmFind object

                        Example:
                           $fm = new fmPDA($database, $host, $username, $password);
                           $findAllCommand = $fm->newFindAllCommand($layoutName);
                  
Find all records
fmPDA::newFindAnyCommand()

                     function newFindAnyCommand($layoutName)

                        Create a new find any object.

                        Parameters:
                           (string)  $layoutName           The name of the layout

                        Returns:
                           A fmFind object

                        Example:
                           $fm = new fmPDA($database, $host, $username, $password);
                           $findAnyCommand = $fm->newFindAnyCommand($layoutName);
                  
Find the first record
fmPDA::newFindCommand()

                     function newFindCommand($layoutName)

                        Create a new find object.

                        Parameters:
                           (string)  $layoutName           The name of the layout

                        Returns:
                           A fmFindQuery object

                        Example:
                           $fm = new fmPDA($database, $host, $username, $password);
                           $findCommand = $fm->newFindCommand($layoutName);
                  
Execute a non-compound find
fmPDA::newCompoundFindCommand()

                     function newCompoundFindCommand($layoutName)

                        Create a new compound find object.

                        Parameters:
                           (string)  $layoutName           The name of the layout

                        Returns:
                           A fmFindQuery object

                        Example:
                           $fm = new fmPDA($database, $host, $username, $password);
                           $findCommand = $fm->newCompoundFindCommand($layoutName);
                  
Execute a compound find
fmPDA::createRecord()

                     function createRecord($layout, $fieldValues = array())

                        Create a record object. The records Commit() method will send the data to the server.

                        Parameters:
                           (string)  $layout           The name of the layout
                           (array)   $fieldValues      An array of field name/value pairs

                        Returns:
                           The newly created record object.

                        Example:
                           $fm = new fmPDA($database, $host, $username, $password);
                           $record = $fm->createRecord('Web_Project', $fields);
                           $result = $record->commit();
                  
Create a record
fmPDA::newAddCommand()

                     function newAddCommand($layoutName)

                        Create a new add command object.

                        Parameters:
                           (string)  $layoutName           The name of the layout

                        Returns:
                           A fmRecord object

                        Example:
                           $fm = new fmPDA($database, $host, $username, $password);
                           $addCommand = $fm->newAddCommand('Web_Project');
                           $addCommand->setField('Name', 'Test');
                           $result = $addCommand->execute();
                  
fmPDA::newEditCommand()

                     function newEditCommand($layoutName, $recordID)

                        Create a new edit record object.

                        Parameters:
                           (string)  $layoutName           The name of the layout
                           (integer) $recordID             The recordID of the record to edit

                        Returns:
                           A fmEdit object

                        Example:
                           $fm = new fmPDA($database, $host, $username, $password);
                           $findAnyCommand = $fm->newEditCommand($layoutName, $recordID);
                  
Edit a record
fmPDA::getRecordById() and fmRecord::commit()

                     Use fmPDA::getRecordById() and fmRecord::commit() to get the record and then commit changes.
                  
Get a record and commit changes
fmPDA::newDuplicateCommand()

                     function newDuplicateCommand($layoutName, $recordID)

                        Create a new duplicate record object.

                        Parameters:
                           (string)  $layoutName           The name of the layout
                           (integer) $recordID             The recordID of the record to duplicate

                        Returns:
                           A fmDuplicate object

                        Example:
                           $fm = new fmPDA($database, $host, $username, $password);
                           $newDuplicateCommand = $fm->newDuplicateCommand($layoutName, $recordID, $duplicateScript);
                           $result = $newDuplicateCommand->execute();
                           if (! $fm->getIsError($result)) {
                              ...
                           }
                  
Duplicate a record
fmPDA::newDeleteCommand()

                     function newDeleteCommand($layoutName, $recordID)

                        Create a new delete record object.

                        Parameters:
                           (string)  $layoutName           The name of the layout
                           (integer) $recordID             The recordID of the record to delete

                        Returns:
                           A fmDelete object

                        Example:
                           $fm = new fmPDA($database, $host, $username, $password);
                           $findAnyCommand = $fm->newDeleteCommand($layoutName, $recordID);
                           $result = $findAnyCommand->execute();
                           if (! $fm->getIsError($result)) {
                              ...
                           }

                  
Delete a record
fmPDA::getContainerData()

                     function getContainerData($containerURL, $options)

                        Returns the contents of the container field. Given the changes with the Data API, you can bypass this entirely if you are
                        simply wanting to display the container with an <img tag. Just take the url returned in the field and feed that into the
                        <img tag.

                        Note that the $options parameter is new to fmPDA - it does not exist in the FileMaker API for PHP.

                        Parameters:
                           (string)  $containerURL      The URL to the container
                           (array)   $options           The options array as defined by fmCURL::getFile(), additionally:
                                                         ['fileNameField'] The field name where the file name is stored on the record
                                                                           This lets the caller specify the downloaded filename
                                                                           if [action'] = 'download'

                        Returns:
                           The contents of the container field

                        Example:
                           $fm = new fmPDA($database, $host, $username, $password);
                           $url = $fm->getContainerData($containerURL);
                  
Use fmPDA::getContainerData() to display the container field contents.

Use fmPDA::getContainerData() to download the container field contents.

Use fmPDA::getContainerData() to download/inline the container field contents.
fmPDA::getContainerDataURL()

                     function getContainerDataURL($graphicURL)

                        This is not needed anymore - just use the URL return in the field data directly. Your existing code will continue to work
                        but it would be best for performance if you modify your code to simply use the URL returned from getFieldUnencoded() and
                        place it in the <img tag directly.

                        Parameters:
                           (string)  $layout           The name of the layout
                           (array)   $fieldValues      An array of field name/value pairs

                        Returns:
                           The same URL passed in

                        Example:
                           $fm = new fmPDA($database, $host, $username, $password);
                           $url = $fm->getContainerDataURL($graphicURL);
                  
Get the URL to the container field and display the container in an <img> tag
fmPDA::newUploadContainerCommand()

                     function newUploadContainerCommand($layout, $recordID, $fieldName, $fieldRepetition, $file)

                        Upload a file to a container field.
                        This method does not exist in FileMakers API For PHP but is provided as the Data API now directly supports this.

                        Parameters:
                           (string)  $layout               The name of the layout
                           (integer) $recordID             The recordID of the record to edit
                           (string)  $fieldName            The field name where the file will be stored
                           (integer) $fieldRepetition      The field repetition number
                           (string)  $file                 An array of information about the file to be uploaded. You specify ['path'] or ['contents']:
                                                               $file['path']       The path to the file to upload (use this or ['contents'])
                                                               $file['contents']   The file contents (use this or ['path'])
                                                               $file['name']       The file name (required if you use ['contents'] otherwise
                                                                                   it will be determined)
                                                               $file['mimeType']   The MIME type

                        Returns:
                           A fmUpload object

                        Example:
                           $fm = new fmPDA($database, $host, $username, $password);
                           $file = array();
                           $file['path'] = 'sample_files/sample.png';
                           $uploadContainerCommand = $fm->newUploadContainerCommand($layout, $recordID, $fieldName, $fieldRepetition, $file);
                           $result = $performScriptCommand->execute();
                           if (! $fm->getIsError($result)) {
                              ...
                           }
                  
Upload a file to a container field
fmPDA::newPerformScriptCommand()

                     function newPerformScriptCommand($layout, $scriptName, $params = '')

                        Execute a script.

                        Parameters:
                           (string)  $layoutName           The name of the layout
                           (string)  $scriptName           The name of the FileMaker script to execute
                           (string)  $params               The script parameter

                        Returns:
                           A fmScript object

                        Example:
                           $fm = new fmPDA($database, $host, $username, $password);
                           $performScriptCommand = $fm->newPerformScriptCommand($layout, $scriptName, $params);
                           $result = $performScriptCommand->execute();
                           if (! $fm->getIsError($result)) {
                              ...
                           }
                  
Run a script