Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

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

Recommended Posts

Posted

Hi there - I am using the Filemaker php API to create a select menu and populate with options -

However, it also returns lots of empty values - where the field being used is empty.

How do I add an omit to the php ?

here is my current code - which does not work :


	$fm = new FileMaker(FM_FILE, FM_HOST, FM_USER, FM_PASS);

	$find_lands =& $fm->newFindAllCommand('COUNTRIES');

//	$find_lands->addFindCriterion('COUNTRY', "=");

//	$find_lands->setOmit(true);	

	$find_lands->addSortRule('COUNTRY', 1, FILEMAKER_SORT_ASCEND);

	$result_lands = $find_lands->execute();

When I run that - I get Fatal error: Call to undefined method FileMaker_Command_FindAll::setOmit() in /Library/WebServer/Documents/project/includes/lands.php on line 14

With the two lines above commented out and using the FindAll it works but with the empty options

Any idea what I am doing wrong /

Many thanks in advance

Glorifindal

Posted

You've got a couple of problems. First, the FindAllCommand is only for finding all the records for the supplied layout. Second, the setOmit() function is only available for a compound find request which would look like this:


$cpdFind = $fm->newCompoundFindCommand($layout);

$req = $fm->newFindRequest($layout);

$req->addFindCriterion("COUNTRY", "=");

$req->setOmit(true);

$cpdFind->add(1, $req2);



$result = $cpdFind->execute();





however in my testing it seems there's a bug in the API that ignores the setOmit = true value if its the only request in the compound find i.e.  the above actually returns all records where COUNTRY == "" but the following works 



$cpdFind = $fm->newCompoundFindCommand($layout);

$req1 = $fm->newFindRequest($layout);

$req1->addFindCriterion("PrimaryKey", ">=0");

$req2 = $fm->newFindRequest($layout);

$req2->addFindCriterion("COUNTRY", "=");

$req2->setOmit(true);

$cpdFind->add(1, $req1);

$cpdFind->add(2, $req2);



$result = $cpdFind->execute();





However since all you want is a list of all records where "COUNTRY" is not empty the following would be the easier route





$find = $fm->newFindCommand($layout);

$find->addFindCriterion("COUNTRY", "*");



$result = $find->execute();

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