Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 3785 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

I'm playing around with the PHP API, and was converting a solution which was originally designed for IWP.

The IWP version had an interesting design: the IWP user had access only to a single-record table with global fields. It would populate these fields, then run a script (which ran with full access permissions) which would do a custom search, and return values (if any) in the global fields. The reason it was designed this way was for security: the IWP user has zero access to the underlying data, which seemed like a smart design given all the issues with IWP (for example, if the user hits 'reload' they would often be moved to seeing record #1 in a given layout).

Anyway, it turns out you can use this technique with PHP. The trick is to remember that PHP in filemaker doesn't use sessions. This means that global variables can be changed, and viewed, but only within a single PHP transaction.

So the way to make this works is as follows:

In FileMaker:
* Set up a 1 record table with global fields and give the PHP user access to this table only.
* Create a layout for this table and give the PHP user access to this layout only.
* Create a script that takes scriptParameter, does a find, and returns data in the global field(s). Give the PHP user access to this script only.


In PHP API: Use the findAnyRecord and setScript commands like this:
 

$find=$fm->newFindAnyCommand($layoutName);
$find->setScript("FilemakerPHPScriptToFindStuff", "apple,banana,pear");
$result = $find->execute();
$rec = $result->getFirstRecord();
$theResult = $rec->getField("gResultField");

Since the fields are globals, there's no worry about one PHP user stepping on another PHP user's data, either, even though they are both accessing the same 1 record table.

Posted

Interesting technique.  

 

I'm not finding a getFirstRecord() method in the API.  Wouldn't it have to be

 

$recs =  $result->getRecords();

$rec = $recs[0];

 

or am I overlooking something obvious (as I often do)?

Posted

Yup, there it is in Result.php in FMS12, too!  It's also found in /Library/FileMaker%20Server/Documentation/PHP%20API%20Documentation/index.html .

 

Another fine example of FileMaker's red-headed stepchild, the PHP API documentation.

This topic is 3785 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.