Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Php api result set contains multiple versions of the first result

Featured Replies

Hello,

I'm new at FileMaker and trying to get data out via the API.

The issue I'm having is when I create a newFindCommand and execute it the resulting record set contains as many rows as there are in the layout but each row is the same. More specifically, each row is a copy of the FIRST row in the database.

 

E.g. I'm looking for products with a product code like 'XXX', of which there should be 7. I get 7 rows back but each one is the same product.

 

I've looked a couple of tutorials online and they do exactly the same operations I do so I'm lost as to why my results come out this way.

 

Any advice?

 

Thanks

  • Author

This is my code for this problem, maybe it will stimulate a response. I haven't been able to track the cause myself yet.

 

$findCommand = $productsFM->newFindCommand($productsLayout);
$findCommand->addFindCriterion('Product Code', 'XX123');
$findCommand->addSortRule('Product Code', 1);
 
$result = $findCommand->execute();
 
if (FileMaker::isError($result)) {
echo "<p>Error: " . $result->getMessage() . "</p>";
exit;
}
 
$records = $result->getRecords();
 
From that point, if I iterate through $records outputting the stock code and description,  for example, I'll get the same stock code and description output x times where is the number of rows returned and the correct number of products in the database matching the query.
 
Is this a glitch in my code, my understanding of FM or something to do with the tables/layouts in FM themselves?
 
Thank you
  • Author

I fixed this be re-installing the API for PHP files (FileMaker.php and the FileMaker folder).

It turns out when I first tried my script I got several errors like this one:

 

Deprecated: Assigning the return value of new by reference is deprecated in C:xampphtdocsfileMakerTestFileMakerImplementationParserFMResultSet.php on line 72

 

I removed the =& new and changed it to = new for each of the lines without issue EXCEPT FOR THE LINE ABOVE. Fixing the error for line 72 then made the FileMaker API return the last row repeatedly. Not sure why but I'm now getting the results back as they should be. 

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.