[FX.php List] filemaker script error catch

Chris Hansen chris at iViking.org
Mon Jun 2 09:27:46 MDT 2008


As far as scripts go, things have gotten better, but it still depends  
what you want to do.  The examples that Lance gives are all cases  
where running a FileMaker script would be a better choice.  Here are  
some things to consider when running scripts:

1) How long does the script take to run in FileMaker client?  This is  
a BIGGIE.  There are some scripts that folks use that take a while to  
run in FileMaker, and this is often a bad idea on the web -- the  
user's browser may even time out the connection.

2) Do you really want all the resulting records returned?  For  
example, if you're creating 40,000 records (or just 20 for that  
matter), odds are you want only the IDs of the resulting records (if  
that) returned.  If you do that in PHP, there's quite a bit of  
overhead for each record created, so running a script, and then  
returning the IDs as delimited in a global field in a single record  
makes a lot of sense.

3) What is the script doing?  PHP is just plain faster or easier for  
many tasks, and doesn't have a 100 concurrent user limit.  So say for  
example that you want all 20 of the records that you just found  
returned, but you want to perform some complex text manipulation on  
the returned data before presenting it to the user; it may very well  
make more sense to do that manipulation in PHP. Also, related to (1)  
above, reports can be one of the big offenders as far as taking a long  
time in FileMaker (summary fields contribute to this), so a report  
viewed via the web may be better assembled using PHP.

4) Will the given script even work via the web?  Before running a  
script via the web, make sure that all of the required script steps  
are web compatible.  MOST will be, but this is something that  
developers need to be aware of when deciding how the various parts of  
a solution will function.

5) Are there many round trips between PHP and the FileMaker server, or  
is just a single chunk of records returned?  This is really a specific  
case of (2) above.  Again, each query adds overhead, so the fewer  
round trips to FileMaker, the better.

In my experience, it's generally obvious when a FileMaker script is  
the way to go, though this distinction has become clearer as I've  
become more familiar with the FileMaker/PHP environment.  When in  
doubt, ask the list =)

HTH

--Chris

On Jun 1, 2008, at 4:42 PM, Kevin Futter wrote:
> On 31/05/08 1:28 AM, "Joel Shapiro" <jsfmp at earthlink.net> wrote:
>
>> Hey Alex
>>
>> Could you have the FM script set a global to Get(LastError) -- and
>> then ExitScript if != 0 -- at places it might fail, and then check
>> the global in the PHP?  Don't know if it would work... just a  
>> thought.
>>
>> As to "not advised"...  That's what I'd always understood but I
>> emailed with Lance Hallberg about this last year, and he replied:
>>
>>> ...certainly depends on what the FileMaker script is doing and what
>>> PHP can do...
>>>
>>> FM scripts can be a big load on the server, but in most cases no
>>> bigger that executing those actions from php.
>>>
>>> For example try running a script from the web which creates 40,000
>>> records.  Now try to do this by purely using PHP.  Notice which one
>>> is faster.
>>>
>>> Consider running batch scripts... such as de-duping... on a large
>>> set of records.  Large inserts or number crunching scripts will
>>> always perform better then FM Script execution than by PHP loops.
>>> Certainly this is mostly due to the need for multiple database
>>> transactions... to the nth degree.
>>>
>>> While the create 40,000 records script is running you can also run
>>> PHP scripts which perform finds, add & delete records.  You can
>>> even execute more FM scripts from php while the previously executed
>>> script is still running.  The notion that the WPE is 'holding back
>>> other queries until done running the script' is completely wrong.
>>> I'm not sure how that ended up on the thread but it could be just
>>> dated facts; perhaps that was an issue with FM 6?
>
> That particular piece of info is very interesting. I'm assuming that  
> Lance
> has inside info on how WPE works? Either way, it sounds like most of  
> the
> reasons for not running scripts from PHP went away with FM 6.


More information about the FX.php_List mailing list