July 24, 201213 yr 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'); } }
July 24, 201213 yr 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