[FX.php List] Setting a global field in IWP using FX.PHP

DC dan.cynosure at dbmscan.com
Fri Apr 21 10:52:35 MDT 2006


The distinction Chris mentions between "local" globals and "server"  
globals in FMP is critical in a web served database. In the web  
serving context "local" globals (normal global fields) are pretty  
useless. Anyone out there have a really good web-centric use for  
normal global fields that can refute that statement? You know, beyond  
the usual use in FMP as variables in scripts.

The difference between "local" globals (normal global fields) and  
"server" globals (one record in a filemaker table):

A) local globals (normal global fields in a table)
0- can be set to a default value (in a professional setting globals  
are usually set by an opening script)
1- only applicable to the user that set them during a web request  
(other users do not see normal globals changing if another user  
changes them)
2- only effective for the duration of a single web request (so you  
can set a global and then run a script via FX that uses that global,  
but you can't set a global and then expect it to be there the next  
web request)
3- always set back to the default (generally the value set by the  
developer in an opening script) at the end of the web request

B) server globals (implemented using non-global fields in the one  
record table - this is important, don't use global type fields, use  
text, number, date, time, container, etc... fields in the one record  
table, and don't add records, server globals work precisely because  
there is only one record. You can think of them like a config file if  
that helps.)
0- can be set to a default value (usually in an opening script)
1- applicable to all users (all users see the same data and can  
change it)
2- maintained across web requests (one request can set the value and  
the next will see the new value)

There are basically two threads here:
1) Multiple users accessing and changing the same field
2) Sequential web requests (from the same user) accessing and  
changing the same field

For #1 you should use server globals because sessions shouldn't be  
shared between users - in fact, I am not sure if it is even possible  
to share sessions across users.
For #2 you probably want to use PHP sessions (because it is easier to  
maintain and debug), but you could use server globals

HTH,
dan

On Apr 21, 2006, at 12:01 PM, Chris Hansen wrote:

> Hello!
>
> At issue here is the fact that global fields are set on a per  
> connection basis, and in the case of XML (as used by FX.php) only  
> last for the duration of the current query.  In other words, no  
> other user would see any change to their globals.  If you want to  
> track information like this, use PHP sessions.  If multiple users  
> need to have access to a single value in FileMaker, consider using  
> a one record table with the shared value in a normal field (i.e.  
> not a global.)  HTH
>
> Chris Hansen
> Application Developer
> The Moyer Group
> chansen at moyergroup.com
> http://www.moyergroup.com/
> -
> Creator of FX.php
> "The best way from FileMaker to the Web."
> http://www.iViking.org/
> -
> FileMaker 7 Certified Developer
>
>
>
> On Apr 20, 2006, at 5:17 PM, Lostpants wrote:
>
>> I'm trying to use FX to set a global field in an IWP database.
>> The 'SetFMGlobal' function doesn't seem to work, and I am not  
>> getting back
>> any errors back.
>> I have read that you have to include session information somewhere  
>> in order
>> to populate a global, but don't see any reference to session info  
>> in the
>> function reference.
>>
>> Here is the page that tries to put, 'hello' into my gloabal field.
>> BTW: the commented line is an experiment to try the adddbparam  
>> function. It
>> too didn't work.
>>
>> <html>
>> <head>
>> <title>Updating a variable using fxPHP</title>
>> <meta http-equiv="Content-Type" content="text/html;  
>> charset=iso-8859-1">
>> </head>
>>
>> <body>
>> <p>This script attemtps to update a global variable in FMPro8 Server
>> Advanced using<br>
>> the AddDBParam, SetFMGlobal and FMFind method from fxPHP.</p>
>> <?
>> require_once($_SERVER['DOCUMENT_ROOT']."/FX/FX.php");
>> require_once($_SERVER['DOCUMENT_ROOT']."/FX/FX_Error.php");
>> require_once($_SERVER['DOCUMENT_ROOT']."/FX/server_data.php");
>> require_once($_SERVER['DOCUMENT_ROOT']."/FX/FX_constants.php");
>> $myQuery=new FX('144.25.180.191',80,'FMPro7');
>> $myQuery->SetDBData('PMRT.fp7','Login');
>> $myQuery->SetDBPassword('Guest','');
>> //$myQuery->AddDBParam('-recid',$id);
>> $myQuery->AddDBParam('gLogin_email','hello');
>> $myQuery->SetFMGlobal('gLogin_email','hello');
>> $myQueryResult=$myQuery->FMFind();
>>
>> if($myQueryResult['errorCode']==0){
>> echo "Database update check: GOOD<br>";
>> echo "<script>window.opener.location.reload()</script>";
>> }else{
>> echo "<font color=\"red\">Database update check: BAD</font><br>";
>> echo $myQueryResult['errorCode'];
>> }
>> ?>
>> </body>
>> </html>
>> _______________________________________________
>> FX.php_List mailing list
>> FX.php_List at mail.iviking.org
>> http://www.iviking.org/mailman/listinfo/fx.php_list
>>
>
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list



More information about the FX.php_List mailing list