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.

find/return one record

Featured Replies

i am working on a site where i am expecting to get back a single row as the result of a search.

i know how to iterate thru all the rows using

foreach ($response->getRecords() as $record ) {}

and I have used this to get a single record by id

$record = $fm->getRecordById('sku_web', $_GET['id']);

but i'm just not sure on the syntax to get the first record from the getRecords() array.

thanks

andy

hi,

I'm using a little trick:

If I'm searching for any field which contains an unique value, I use:

$records = $result->getRecords();

$record = $records[0]; // There is only the first one ;-)

$field = $record->getField('FileMakerField');

Searching a record ID looks like:

$data = $fm->getRecordById('layout', $_SESSION['record_id']);

$name = $firmendaten->getField('Name',0);

Hope, this helps a little bit.

/horst

$data = $fm->getRecordById('la yout', $_SESSION['record_id']);

$name = $firmendaten->getField ('Name',0);

Probably a typo, should be:

$data = $fm->getRecordById('layout', $_SESSION['record_id']);

$name = $data->getField ('Name',0);




$records = $result->getRecords(); $record = $records[0]; // There is only the first one ;-) $field = $record->getField('FileMakerField');
Works, but i prefer:

$record = current($result->getRecords());

$field = $record->getField('FileMakerField');

Thanks Genx!

Of course there was an error in the first part!

Thanks for the

$record = current($result->getRecords());

/horst

  • 3 weeks later...
  • Author

i ended up using code like this...

// perform find

$result = $cmd->execute();

// get results

$records = $result->getRecords();

$records[0]->getField('FName');

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.