Function Reference for FX.php

This document is intended to demonstrate the functions in FX.php. Almost all of the functions within FX can be called in any order. There are two exceptions: 1) a declaration of an instance of FX must come before the others; and 2) one of the query functions must be called last. The functions in each section include descriptions of what they do, their parameters, and sample code.

In the original 2001 release, the FX class was called FMData() instead.

First Function to Call

FX($dataServer, $dataPort, $dataType, $dataURLType='')#

The constructor method of the FX class. Used with the keyword new to create and return a new FX object.

$dataServer - the address of the machine where your data source is running.

$dataPort - (optional) the port on which your data source is listening. Defaults to 80.

In the case of FileMaker® Server (version 7 and later), FileMaker® data will be accessible on the web server port on that machine. This will usually be port 80, or port 443 for SSL connections.

In FileMaker® Pro 5 and FileMaker® Unlimited 6, this can be configured under the "Edit" menu on most platforms or the "FileMaker Pro" menu in Mac OS X under:

Preferences > Application > Plug-Ins

Then select "Web Companion" and click the "Configure..." button. There will be a box where the Port Number can be entered. This is set to port 80 by default, but it states in the FileMaker® help (under "Web Companion, Specifying a port number for web publishing"):

FileMaker, Inc. has registered port number 591 with the Internet Assigned Numbers Authority (IANA) for use with FileMaker Pro Web Companion.

If neither of these ports works for you, you might also consider using one of the ports between 49152 and 65535. According to IANA, these ports are considered Dynamic and/or Private. That is to say, they aren't registered to any specific application.

$dataType - (optional) the type of data source that will be accessed. Default is set via the $dataServerType and $dataServerVersion attributes of the FX object.

If you will always (or almost always) be accessing the same type of data source, you can simply change the default via these lines in FX.php:

var $dataServerType = 'xxxxx';
var $dataServerVersion = 7; // ignored for non-FM data sources

$dataServerVersion should mirror the version of FileMaker® data being used. Note that the numbers 5 and 6 are functionally equivalent, as are numbers 7 and greater.

The possible values for xxxx (case is not important) are:

FMPro - for FileMaker® data sources.
ODBC - to connect to an ODBC data source.
MySQL - if connecting to a MySQL server.
OpenBase - if connecting to an OpenBase data source.
PostgreSQL - for connections to PostgreSQL.
CAFEphp4PC - when using FMWebschool's CAFEphp with FileMaker® client on the PC.

$dataURLType - (optional, FMS ≥ 7 only) possible values (case insensitive): HTTP (assumed) or HTTPS. Used to connect to FileMaker® Server via SSL.

Returns an FX object. Its functions will allow you to set up and then execute a query. After executing a query, the FX object has a number of attributes you will find useful:

$lastLinkPrevious - link to the previous "page" of data
$lastLinkNext     - link to the next "page" of data
$lastFoundCount   - number of records/rows from query
$lastFields       - array of field/column data
$lastURL          - URL of query, if FileMaker
$lastQuery        - SQL of query, if relevant
$lastQueryParams  - parameters used to generate query
$lastErrorCode    - error code associated with query
$lastValueLists   - FileMaker value lists, as appropriate
$lastDebugMessage - debug message, if any

/* quick FX call that will return a random record from FMS7 or later */
$serverAddress = '192.168.22.11';
$serverPort = 80;
$serverType = 'FMPro7';
$username = 'web_user';
$password = 'password';
$databaseName = 'Contacts';
$layoutName = 'web_Contact';

$query = new FX($serverAddress, $serverPort, $serverType);
$query->SetDBUserPass($username, $password);
$query->SetDBData($databaseName, $layoutName);
$randomRecord = $query->DoFXAction('show_any');