Jump to content
Server Maintenance This Week. ×

FX.PHP -- Sorting -- FM8


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

Recommended Posts

Hi Andy; Yes I've tried sorting with any of the fields and i have the same result. OK now I'm really puzzled. I thought since no one at iviking or fmwebschool were replying, that I would give FM-AND-PHP a try and see how it fairs. Exactly the same result with it as well.

Question: Did you do anything at all during your diagnosis of your problem other than cut/paste of the code? apply any patches/upgrades etc?

I am using the latest (downloaded yesterday) versions of fx.php and fx-and-fm just to be safe.

I will attach the database. Perhaps you can see if it does the same on your system?

Here are the queries; first in FM-and-PHP and then in FX.PHP:

include("fmandphp.php");

$FM = new FM_and_PHP();

$FM->setFileMakerHost("192.168.1.4","80","7");

$FM->setDatabaseName("test");

$FM->setDatabaseLayout("test");

$FM->setDatabaseUserPassword("admin","");

$FM->setMaxGroupSize(10);

$FM->addSortParameter("rank",$sortorder="ascend");

$FM->setSkip($_REQUEST['skip']);

$FM->setCommand("findall");

$FM->doQuery();

if ( $FM->getErrorNumber() != 0 ) {

echo "EN: The following error occurred ";

echo $FM->getErrorDescription();

die();

}

While ( $FM->getNextRecord() ) {

echo $FM->getField("rank");

echo "


";

}

and now FX.PHP

include_once('FX/FX.php');

include_once('FX/server_data.php');

$groupSize = 50;

$productid=5001;

$InstanceName = new FX($serverIP,$webCompanionPort,'FMPro7');

$InstanceName ->SetDBData('test.fp7','test',$groupSize);

$InstanceName ->SetDBPassword('','admin');

$InstanceName ->AddDBParam('productid', $productid);

$InstanceName ->AddSortParam('rank','ascend');

$ReturnedData = $InstanceName->FMFind();

$returnedCount= $ReturnedData['foundCount'];

echo $ReturnedData['errorCode'].'
'.'
'.'
';

echo $returnedCount;

foreach($ReturnedData['data'] as $key=>$productsData);

?>

productidpricerank

<? foreach($ReturnedData['data'] as $key=>$productsData){ ?>

<? echo $productsData['productid'][0]; ?><? echo $productsData['price'][0]; ?><? echo $productsData['rank'][0]; ?>

<? } ?>

test.zip

Edited by Guest
Link to comment
Share on other sites

AHHHHHHHHHHHHHHHHHHHHH!!!!!!!!!!!!!!

Dammit! LOL. OK stupid stupid stupid me. We had recently built a new FM Server for this project.... and after installing it someone (namely me) forgot to apply the patch from filemaker to update to the latest version of the web engine....

>>> BLUSH <<< Everything is working just fine now.

So... apart from the other issues, we can add that FX.PHP AND FM-and-PHP will not sort records unless you patch the engine.

Im gonna crawl into a hole now...

S

Link to comment
Share on other sites

  • 2 weeks later...

OK, seems this little issue keeps rearing its ugly little head.

If you are using FX.PHP and running FMS8A please let us know if you have any issues with scripts ignoring your Sort settings.

This only applies if you use the

$query -> AddSortParam('Your Field','sort order');

This is an intermittent issue which appears to resolve itself after a period of time (anywhere from 1-several hours). We are right now running a looping test on the FMPug website to see if we can find a pattern.

So far we have seen the issue on Windows Server based machines. If you do have any issues, please let us know along with your server machine spec.

Link to comment
Share on other sites

Update on this issue.

We have run tests over the past few days.

The Test

Run a query on a set of records that was created out of a natural sort order. Then query the database table including a sort query that puts the records into ascending order. After each query write a record to a separate table, capturing the order of the records as returned by the query AND write the result of the FX.PHP array to a second field. Repeat this every 5 seconds

The test environment:

FileMaker Server 8.0v1a (8.0.1.28)

Windows IIS

PHP Version 5.0.1

1 table containing three records, with a single text field. The contents of the field (in creation order) are;

  • C
  • A
  • B

A query was run on these records detailed below;

$layout = 'Test_SortIssue';



$query = new FX ($serverIP, $webCompanionPort);

$query -> SetDBData($webDB,$layout);

$query -> SetDBPassword($webPW,$webUN);

$query -> AddSortParam('TestField','ascend');



$queryResult = $query -> FMFindAll();





The results of this query were then collated




$result=NULL;

foreach ($queryResult['data'] as $key=>$value) {



$result.= $value['Name'][0];

}

$XMLoutput = print_r($queryResult, true);





This information was then written to another table in the database




$layout = 'Test_SortResponse';



$query = new FX ($serverIP, $webCompanionPort);

$query -> SetDBData($webDB,$layout);

$query -> SetDBPassword($webPW,$webUN);

$query->AddDBParam('Result_sort',$result);

$query->AddDBParam('XMLoutput',$XMLoutput);

$queryResult=$query->FMNew();





The page was then refreshed on a 5 second interval


 

The results

We have collected 45423 records. Granted we had a few outages due to interruption in internet connectivity and loss of signal to the database but the results will speak for themselves.

Total Records = 45423

Correctly Sorted = 38929

Incorrectly Sorted = 6494

Percentage of failure = 14.29%

Conclusion

The failures did not happen at specific times , or for similar durations. The failures ranged from 15 seconds to several hours in length.

This is worrying indeed as the problem is erratic and intermittent and not easily identifiable.

We have begun looking at ways of recoding the queries to not rely on the sorts from FileMaker until this issue can be addressed. This will mrean the creation of secondary mutlidimensional arrays based on the FX.PHP array and then sorting this new array. This may cause latency issues in page deliveries which we will notify you of as we get into further testing.

For now we have one page that takes a FileMaker query and then builds a secondary array that is sorted on one of the values and the page is built. This page is located at http://www.fmpug.com/pugfriends.php

Please let us know if you experience significant delays in this page.

Please note: This has been noted so far ONLY on Windows based Servers.

I request any one in the community using FX.PHP, specifically those pages using AddSortParam queries to monitor those pages for intermittent errors.

For now we have an alert mechanism in place on the FMPug website that if the sort order fails on ANY page a message will be displayed below our advertisers banners alerting you to this. we are working with FMI on this issue.

Link to comment
Share on other sites

Hello,

I'm here just to add some information:

I experienced the same sorting problems but not only with FX.php (see my latest topic here ) .

I would like to highlight this:

I opened the publishing engine logs (pe_application_log.txt) and I've found a lot of lines wich report the error 404 (invalid sort)..

my sort query was like this:

-sortfield.1=field&-sortorder.1=ascend

so, i deleted the sort order param (ascend should be the default order for fm)

and the log still report the error 404

I deleted the -sortfield param (no sort specified) and the log report 404 once again (no sort specified!!).

FMSA 8 v1a on a Windows 2003 server machine.

Hope FMI fix this bug.

Link to comment
Share on other sites

Just to let you know the progress so far.

It seems this is not related just to FX.PHP sort requests.

It appears that FMS8A will completely disregard ANY sort requests, including those for portals that have a sort order on them in FileMaker when sending the XML data back to the browser.

All records revert to the creation order when viewed through the browser, yet when looked at through the FileMaker client, the sort order is fine. So this does seem to lead us to the FMPXMLRESULT again.

We will keep you posted as we test (so far over 85,000 test records have been generated allowing us to compare outages with server logs and other sources of info)

Link to comment
Share on other sites

  • 3 weeks later...

I just want to let know that we are experiencing the same issues with FM and PHP on a Windows 2003 server.

All kinds of sorts have stopped working for about a week now and we have not found a solution to this problem yet.

Thanks

Link to comment
Share on other sites

  • 1 month later...
  • 2 weeks later...

Hello..

I can't say that this is a progress but, after contacting FMI (through the italian filemaker support) , they told me that it could be a missing '-max' parameter to cause the sort failure, or to make browser handle the record in a wrong way.. as we all know browser just download pages and informations.. it doesn't handle the record.. so I don't think I can call my self satisfy.

The only thing I can say is that filemaker 7 used to be a better tool for web publishing than filemaker 8 (v3) is.

Link to comment
Share on other sites

This is NOT related to a missing -max parameter.

This is also not just related to FX.PHP sort params. In fact, if you have a sorted portal on the layout it will revert to creation order as well.

The 8.0v3 update did NOT fix this bug on Windows servers. This is not affecting Mac servers.

Currently, the only way around this is to build new arrays from the returned FX.php array of data and then sort that new array.

We will keep you posted as we find out any new information.

Link to comment
Share on other sites

  • 3 months later...

Currently, the only way around this is to build new arrays from the returned FX.php array of data and then sort that new array.

Does anybody have sample code of this that they would be willing to share?

Thanks!

steven durow

Link to comment
Share on other sites

Here is a sample piece of code to create a new array from the FX.PHP array


include_once('FX/server_data.php');

include_once('FX/FX.php');

$layout = 'LAYOUT NAME';



$query = new FX ($serverIP, $webCompanionPort); $query -> SetDBData($webDB,$layout); 

$query -> SetDBPassword($webPW,$webUN);



//Your search requirements here



$queryResult = $query -> FMFind();



//Loop through your FX array building a new array //Build new array from FM array 

//Create a variable for the array first $newArray = array (); 



foreach ( $ queryResult ['data'] as $key=>$Value ){

   $newArray[] = array ($firstfield,$secondfield,$thirdfield...);

}




//sort the new array using assort




asort($newArray);




//Now you can use this new array on your page to echo the data




foreach($newArray as $key => $value) {



echo $value[0]; //This will echo out $firstfield



echo $value[2]; //This will echo out the thirdfield



}

You may want to read up on arrays and array sorting at www.php.net arsort(), rsort(), ksort(), and sort().

Link to comment
Share on other sites

  • 6 months later...

I just stumbled onto this thread. Is there any news on this issue?

Yesterday our FileMaker Advanced 8.0v2 / Windows Server 2003 system started experiencing this exact same problem. We are using fx.php

Does anyone know if 8.0v4 is any help? We are looking to apply updates in a couple of weeks anyway.

Are there any theories as to the cause? If I can avoid this bug, and avoid having to sort via PHP that would be great.

Last but not least, I read elsewhere that restarting the Web Publishing Engine resolves this (at least temporarily). Unfortunately our server is in a different building and my remote access to it is very limited, but I have put in a request for this.

I'm glad I found this thread!

-Carmen

Link to comment
Share on other sites

This topic is 6243 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.