Home
Username:
Password:
FileMaker 9 & PHP Foundations Tutorials

Performing Advanced Finds / Compound Finds pt. 2




Visitors to VTC.com will be able to view all introductory videos for each training course.
Free Trial Members will gain access to first three chapters for each training course.
Full Access Members have full access to VTC.com’s entire library of video tutorials.


Learn More

Subtitles of the Movie

Let's continue on now with writing the code to complete a compound find. Let's look at the API documentation so we know exactly what the specifications are. We know that with the FileMaker class, we can create a new compound find passing the name of the layout that will give our find scope or the table occurrence. So we'll just say that our compound find is equal to, and we have to use the FileMaker object, new compound find. And then the layout name, which is going to be the same as the other finds. Now that we have a compound find, we need to add find requests. We need to create the find requests first before we can add them. Our first find request will be called request one and it will be equal to a new find request. And we need to pass the name of the layout again. On the find request one, we'll say it's equal to FM new find request. And we need to specify the name of the layout. Once we've created find request one, we can add find criteria. Before we do that, let's create our second find request as well. So we have find request one and find request two and then we're going to add them to a compound find. Before we do that, let's go ahead and add our find criterion. If we look at the find request object, you're going to see that we have the ability to add find criterion just like we did with a regular find command. We can also clear find criteria. But there's a third object or method here that we haven't seen before and that's called set omit. This is the only command or the only place where you have a method to use the omit option like you do in FileMaker. So if you want to perform a find, you can select omit for a particular request. You can do the same with the API when you're doing a compound find. To add the find criteria, you simply call the method of the same name for your find request. Because of that, I'm just going to copy our previous ones and paste them here. All we need to do is number one, change our find request or the object name and then verify that the item or the post value name is correct and it is. Now we can just copy the same code and use it also for our second request and again, we just need to make sure that our variable name matches for our object. And then we need to make sure that we're passing the right names or values from the post array. And for our second request, we're going to use the fields that have the number two appended on their name. That completes our first find request and our second find request. Now what we have to do is add them to our compound find. When we look at our compound find documentation, we have a simple add method where we specify the precedence. In other words, which find request is going to be first and then the name or the variable of the find request. So we'll say compound find add. The first one is going to be request one. And the second one is going to be request two. This completes our compound find setup. Now all we need to do is called it's inherited execute method. Same as the other find or command objects. So we'll say result is equal to compound find execute. Now we have a result object, hopefully, and not an error object. But we don't need to test for that here because after our conditional loops, we're checking for errors down here. Let's go ahead then and try to test this code out. First we'll find our single request. Again, we'll look for any item that has the word com and we perform find and successfully we have two records. Now we'll go back to our search and let's perform the same find we did in FileMaker where the item was a computer desk and the category was office furniture. And then our second request, the category was computers and then the model contained the letter A. Check our box that says add second request so that we match the condition. Remember, in FileMaker, we ended up with six records found. When we hit perform find, we have an error on line 11. Well, let's troubleshoot our error here real quick. Compound find is equal to FM new compound find. Web description. And the problem is going to be, Make sure we have the exact syntax here. There we go. Compound find command. Now let's refresh this in the browser and we have our six records. So with a little troubleshooting, which is always good to do, we have our successful compound find. So this is how you can do two things in your API code. One is you can combine the logical or with the logical and in your find to get a ready robust find found set, just as you would in FileMaker and you can also use the ability to omit one of those requests just as you do in FileMaker when you select the omit checkbox in your find request. This concludes our advanced topic on performing finds with the API and how to use the compound finds in the FileMaker class.

Tutorial Information

Course: FileMaker 9 & PHP Foundations
Author: Lance Hallberg
SKU: 33786
ISBN: 1-933736-99-2
Release Date: 2007-08-22
Duration: 9.5 hrs / 107 lessons
Work Files: Yes
Captions: For Online University members only
Compatibility: Vista/XP/2000, OS X, Linux
QuickTime 7, Flash 8

VTC Sign up & Benefits

  • Unlimited Access
  • 98,729 Video Tutorials (23,265 free)
  • Video Available as Flash or QuickTime
  • Over 1026 Courses
  • $30 for One Month Access
  • Multi-User Discounts Available