Jump to content

Get records from 2 filemaker tables from php


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

Recommended Posts

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');

    }

}

Link to comment
Share on other sites

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;

	 }

}

Link to comment
Share on other sites

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