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.

Get records from 2 filemaker tables from php

Featured Replies

Please find the below code that im trying to display the company name and also product name,

Here both tables are separable. when im get the company details its working fine.. when i try to get the product table records based on the company id, I found the error "Fatal error: Call to undefined method FileMaker_Error::getRecords()"

Please help to resolve this issue


//Get all company details from company layout (company table)

$findCommand = & $fm->newFindAllCommand('company');

$result = $findCommand->execute();

$records = $result->getRecords();



//dispaly the company

foreach($records as $record) {

    echo $record->getField('name')

    echo $cid = $record->getField('id');



    //get products from procut layout base on the company id (prodcut table)

    $findproduct = & $fm->newFindCommand('products');

    $findproduct ->addFindCriterion('cid', $cid);

    $findresult = $findproduct->execute();

    $products = $findresult->getRecords();

   

    foreach($products as $product) {

        echo $product->getField('productname');

    }

}

It appears that an error is being generated by $findresult. Trap for it with

$findresult = $findproduct->execute(); //existing code

if (FileMaker::isError($findresult)) {

	$dbmsg = '<p>Database products error (' . $findresult->code . '): ' . $findresult->getMessage() .'</p>';

	echo $dbmsg;

	exit;

}

// continue your code




This will echo something like

"Database products error (401): No records match the request."

and allow you to troubleshoot your find request.



If you add this code after each find request with the appropriate change in the message text, you can pinpoint which find request won't allow you to get records.  You can also add if statements to, for example, do something different if the found set is empty.
if (FileMaker::isError($findresult)) {

	 if($findresult->code == '401'){

		 // add code to handle no found records

	 } else {

$dbmsg = '<p>Database products error (' . $findresult->code . '): ' . $findresult->getMessage() .'</p>';

		 echo $dbmsg;

		 exit;

	 }

}

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.