[FX.php List] Update a field in all related records.
Greg Lane
glane at moyergroup.com
Fri Mar 17 11:56:05 MST 2006
PHP scripts are very fast. The problem occurs when you have to send a
lot of requests to FMSA. For instance, if you want to delete or
modify a found set of records, FX.php (and FMSA's XML interface)
require you to make a separate request for each record. The overhead
of each of these requests can cause the PHP script's performance to
suffer. However, in some cases you can accomplish the same thing with
a single request by performing an FM script.
Consider a case where you want to delete all account records where
status="expired". You could have your PHP script find all of the
records where status="expired" and then loop through those records,
sending an FMDelete for each one. That works fine for a few records,
but it doesn't scale well. A better option would be to use a "Delete
All" FM script with an FMFind. A safer option might be to encapsulate
all of the logic into a "Delete Expired Accounts" FM script which
goes to an appropriate layout, finds expired records, and deletes
them. Then perform that script with an FMFindAny. You can also have
the script pass a result back to FX.php through a global so you know
if the script executed successfully.
My rule of thumb is that if I find a situation where I need to make
FX.php calls within a loop, I try to find a better way. This becomes
even more important if your web server and FMSA server are in
separate locations. The extra latency can really add up.
Greg
On Mar 16, 2006, at 11:22 PM, Joel Shapiro wrote:
> I'm surprised (pleasantly!) to hear that calling an FM script could
> have better performance than having PHP do all the processing.
> I've got a project doing something similar to Joe's task, and I use
> an FM script, but I'd thought I was just being lazy and that an
> "all PHP" solution would be faster/stronger/more reliable... (and
> that maybe I'd get around to switching it someday ;)
>
> Are there any guidelines or 'rules of thumb' about when using a
> FileMaker script is preferable to PHP scripting?
More information about the FX.php_List
mailing list