[FX.php List] carry data over

Jonathan Schwartz jonathan at eschwartz.com
Wed Sep 6 11:03:39 MDT 2006


Alex,

Ahem...I am now the "Former Beginner", and soon graduating to "Over 
Confident Novice".  ;-)

A couple things to know:

(Expert users...feel free to correct me as I attempt to teach)

1) There is a *wealth* of data that goes to and comes back from 
FMP/fx.php every time you talk with the server.  It is a very 
worthwhile suggestion to place a handful of standard php commands on 
your pages to see what goes on behind the scenes.  With these arrays 
visible, the whole conversation between fx.php and FMP and your 
scripts starts to make a whole lot more sense.

Two  examples:
This one shows all the data that is returned from FMP/fx.php after a query:

//********** SEARCH RESULT***************
echo "<pre>";
print_r($searchResult); //replace the "$searchResult" with the name 
of your own variable.
echo "</pre>";
///********** SEARCH RESULT***************

  This one shows the exact query that fx.php delivers to FMP Server Advanced:
//************DEBUG***********
define("DEBUG", true);
//************DEBUG***********

2) The recid is contained within the arrays that come back from FMP. 
You need to insert a couple lines of code to extract it. The code 
itself depends on whether you have one or mulitple records coming 
back, and whether you want to include the recid in a link on a list 
of records, for instance.

Here is an example of the Explode command that I use to extract the 
recid when a list of records is returned:
		foreach($searchResult['data'] as $key => $value) {
		$recordDetails=explode('.',$key);
		$currentRecord=$recordDetails[0];
		}

Here's how it breaks down:

The array that comes back from fx.php has the recid looking like 
this: 12345.123.  The first part of the string is the actual internal 
recid of the record in FMP.  The second part of the string is the 
number of times the record has been edited.  You want to separate the 
recid.  The explode command does that, much like the 
Left(field(position(field, ".", "1', "1') ) would work in native FMP.

The result is grabbing the recid for that record.

You can also view the recid in native FMP by using the 
Get(RecordNumber) calc field.  Put it on your layout and then you can 
see what is going on.

Does that help?

It took me a *long time* to put these pieces together. If folks see a 
value of a "former beginner" explaining things in this fashion, 
please let me know.  I can do more.

Cheers

Jonathan


See the [0] at the end of $recordDetails?  This means: grab the first 
value you find in the array called

>Dale and Jonathan,
>
>I never realized it was possible to parse the recid out of the FX array.
>
>Jonathan--> you always claim to be the "resident beginner," but believe
>me, you are strides ahead of me.
>
>Would you mind sharing how to parse the recid out of the FX array?  If
>there is no field on the layout, how do you get it?
>
>Thanks!
>
>Alex P. Gates
>
>-----Original Message-----
>From: fx.php_list-bounces at mail.iviking.org
>[mailto:fx.php_list-bounces at mail.iviking.org] On Behalf Of Dale Bengston
>Sent: Wednesday, September 06, 2006 10:50 AM
>To: FX.php Discussion List
>Subject: Re: [FX.php List] carry data over
>
>Jonathan,
>
>I was addressing the fact that it's not necessary to hit your FMP 
>table with a FMFind() immediately after performing FMNew() ... or 
>FMEdit() for that matter ... to obtain the record data.
>
>In the scenario presented by the original poster, the second input 
>form is presented to the user as the "landing" page from the first 
>form submit, which would require no additional FMFind(). If it's 
>possible for your users to move around non-linearly, then yes, 
>absolutely, you would need to keep track of the record id or a 
>primary key to retrieve the record again.
>
>As for retrieving the record id, I prefer to just parse it out of the 
>FX array since it's already there, rather than create a redundant 
>calc field that exposes it in the field data. Whenever possible, I 
>let PHP do the work instead of FMP. It's faster that way.
>
>Dale
>
>
>
>On Sep 6, 2006, at 10:24 AM, Jonathan Schwartz wrote:
>
>>  Chiming in...
>>
>>  That is the case when the second page containing the FMNew response 
>>  also contained the second form...or at least performed an include 
>>  for the second form.  Otherwise, we'd be looking into setting 
>>  variables in sessions to track the recid. Correct?
>>
>>  I'm making this distinction because many of the examples and 
>>  tutorials out there offer a simple form->form response scenario, 
>>  and don't address the reality of a continuous process which can 
>>  involve multiple forms in the process as well as multiple functions 
>>  on the same page.
>>
>>  Gary...this was a major stumbling block in my own learning curve of 
>>  how to track the same record throughout a series of pages.  Once I 
>>  learned how to use "sessions", it was smooth sailing.  I encourage 
>>  you to get this under your belt as soon as you can.
>>
>>  Jonathan
>>
>>>  Actually, you don't need to re-find the record you just created. 
>>>  The variable you set to be the result of FMNEW() contains the 
>>>  typical FX data array for a single FMP record, including the 
>>>  record ID. You can reference this in the second form.
>>>
>>>  Dale
>>>
>>>  On Sep 6, 2006, at 7:13 AM, Alex Gates wrote:
>>>
>>>>  Gary,
>>>>
>>>>  You'll need the recid of the page you want to edit -
>>>>  On your FileMaker layout, create a calculation field that is
>>>>  Get(RecordID) http://www.filemaker.com/help/FunctionsRef-251.html
>>>>
>>>>  Before you move to the second page, you'll first need to find the 
>>>>  record
>>>>  you just created.  Bring back the record ID, make it a session 
>>>>  variable,
>>>>  and use it on the following pages as the parameter in your edit.
>>>>
>>>>  Your edit will look something like this:
>>>>
>>>>  $edit=new FX($serverIP,$webCompanionPort,'FMPro7');
>>>>	$edit->SetDBData('FileName.fp7','LayoutName');
>>>>	$edit->SetDBPassword('password','username');
>>>>	$edit->AddDBParam('-recid', $recid);
>>>>	$edit->AddDBParam('AdditionalField1', $additionalfield1);
>>>>	$edit->AddDBParam('AdditionalField2', $additionalfield2);
>>>>  //(and so on)
>>>>	$editResult=$edit->FMEdit();
>>>>
>>>>
>>>>  The Ultimate Guide to FileMaker and PHP is a really great resource -
>>>>  page 152 walks you through a wonderful example.
>>>>
>>>>  http://www.fmwebschool.com/filemaker_php.php
>>>>
>>>>  I hope this helps - - I didn't go step by step through 
>>>>  everything, but
>>>>  the Ultimate Guide does - - I've used it a lot and I find it very
>>>>  helpful.
>>>>
>>>>  If anyone has anything to add that I have forgotten, please do so.
>>>>  I'm still trying to get my feet wet with this stuff, but I like 
>>>>  to try
>>>>  to help whenever I can...
>>>>
>>>>  Alex P. Gates
>>>>  -----Original Message-----
>>>>  From: fx.php_list-bounces at mail.iviking.org
>>>>  [mailto:fx.php_list-bounces at mail.iviking.org] On Behalf Of Gary 
>>>>  Redmond
>>>>  Sent: Wednesday, September 06, 2006 3:19 AM
>>>>  To: FX.php Discussion List
>>>>  Subject: [FX.php List] carry data over
>>>>
>>>>  Ok I have a form that asks a user for their name etc, when they 
>>>>  press
>>>>  submit it adds the details to a new record however, I would like 
>>>>  to have
>>>>
>>>>  another form on the next page that allows them to add more to the
>>>>  record.
>>>>
>>>>
>>>>  _______________________________________________
>>>>  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
>>>
>>>  _______________________________________________
>>>  FX.php_List mailing list
>>>  FX.php_List at mail.iviking.org
>>>  http://www.iviking.org/mailman/listinfo/fx.php_list
>>
>>
>>  --
>>
>>  Jonathan Schwartz
>>  FileMaker 8 Certified  Developer
>>  Associate Member, FileMaker Solutions Alliance
>>  Schwartz & Company
>>  jonathan at eschwartz.com
>>  http://www.eschwartz.com
>>  http://www.exit445.com
>>  415-381-1852
>>
>>  _______________________________________________
>>  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
>
>
>
>
>_______________________________________________
>FX.php_List mailing list
>FX.php_List at mail.iviking.org
>http://www.iviking.org/mailman/listinfo/fx.php_list


-- 

Jonathan Schwartz
FileMaker 8 Certified  Developer
Associate Member, FileMaker Solutions Alliance
Schwartz & Company
jonathan at eschwartz.com
http://www.eschwartz.com
http://www.exit445.com
415-381-1852
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.iviking.org/pipermail/fx.php_list/attachments/20060906/d4b37cbe/attachment-0001.html


More information about the FX.php_List mailing list