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

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

Recommended Posts

Posted (edited)

I've been stuck on the syntax of performing a fairly simple find through the API. For our events calendar, I want to be able to find events that happen after today. What is the proper way of specifying this find?

The line I'm having trouble with is $request2->addFindCriterion('Concert_Date', '>='.$today);

What's the simpler way of asking this?

Are there any solid resources for stuff like this? I have the book FileMaker Web Publishing and the white papers from FileMaker, but nothing seems to have an expansive resource for syntax.

                <?php

                    $today = date("m/d/Y");

                    $request = $fm->newFindRequest('Web_Concert');

                    $request->addFindCriterion('Show_in_Sidebar', 'Yes');



                    $request2 = $fm->newFindRequest('Web_Concert');

                    $request2->addFindCriterion('Concert_Date', '>='.$today);	



                    $compoundFind = $fm->newCompoundFindCommand('Web_Concert');

                    $compoundFind->add(1,$request);

                    $compoundFind->add(2,$request2);

                    $compoundFind->addSortRule('Concert_Date',1,FILEMAKER_SORT_ASCEND);

                    $compoundFind->setRange(0, 5);



                    $result = $compoundFind->execute();



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

                        echo "
Error: " . $result->getMessage() . "";

                        exit;

                    }



                    $records = $result->getRecords();

                    

                    foreach ($records as $record)

                    {

                        $title = $record->getField('CCCalAppts::ApptTitle');

                        $desc = $record->getField('Website_Desc');

                        echo '

[*]'.$desc.'

                        ';

                    }

		        ?>

This creates a valid find, but the results seem to be all dates.

jon

Edited by Guest
Posted

I believe that the line should read...

$request->addFindCriterion('Concert_Date', ">=3/19/08");

So that PHP parses the code (it doesn't do it with single quotes, but does with double).

But that brings up a bigger problem that I will start in another thread.

jon

Posted

$request2 = $fm->newFindRequest('Web_Concert');

$request2->addFindCriterion('Concert_Date', '>='.$today);

That should work fine, but you do realize your compound find request is asking for events after today or those that are supposed to be featured in the side bar?

Posted

Yeah, I changed the find after looking at it...

The command I gave above does work, using the double quotes. But it doesn't work all the time. It appears to be related to my other post about referenced fields not coming through. Trouble is, they come through sometimes. And it appears to be very random on how and why it does it. Most of the time the fields don't pass through. My test server machine is a Mac Mini, could it be related to the speed it takes to pass and parse the different variables related to the page? This is not at all worth anything as a true production website if it only works sometimes. I've attached a screenshot that shows the same page just being refreshed and showing the two different outcomes.

If you want to take a look at the site, give it a try here http://141.209.36.46/somsite but realize its far from complete.

jon

Picture_3.png

Posted (edited)

Doesn't work externally.

To clarify, the code should be... And the double quotes is a PHP thing, try echo date('m/d/Y') vs echo date("m/d/Y") on a separate page.


$find = $fm->newFindRequest('Web_Concert');

$find->addFindCriterion('Show_in_Sidebar', 'Yes');

$find->addFindCriterion('Concert_Date', '>='.date("m/d/Y"));

$find->addSortRule('Concert_Date',1,FILEMAKER_SORT_ASCEND);

$find->setRange(0, 5);

$result = $find->execute();

Edited by Guest
Posted

Yeah, I just tested it externally. Somewhere the DNS wants to change it to the computer name, just go ahead and type in 141.209.36.46 instead of the name it brings up.

Thanks for the help on that code, but it looks like it's a moot point till I get the other thing figure out.

jon

Posted

That code is anything but moot point. If its not working then something is wrong on a deep level.

Posted

I went ahead and skirted my other issue by creating fields by calculated value which really aren't what I would like to do, but in our scenario where the fields really won't change that often, I can get away with. With that connection working I was able to figure out that the code you gave does work perfectly.

$find->addFindCriterion('Concert_Date', '>='.date("m/d/Y"));

Thanks again!

jon

Posted

Yeh, but it should still work over multiple files... Out of curiosity, whats the file reference you have pointing from one file to the other? i.e. the path.

  • 2 weeks later...
Posted

For the reference, try using file:CCCalendar_SchedulingEdition instead? I forget how many forward slashes you're meant to use after the file: (if any). Point is, if their on the same server, that ref should work - and it might just help.

Posted

I like the way my workaround works on the other database because I need to be able to change some of the info, but I ran into the same issue in tying another db in and this solution worked! (at least so far...)

There are actually no slashes when just specifying a file. Simply...

file:FileName.fp7

Thanks for the tip.

jon

Posted

Actually it was consistent for most finds, but then when I went to a find which displays a bunch of records in different tables, it would die randomly on different page loads. Very strange, computers stink when they're not consistent.

To fix the inconsistencies that time I went back to managing data sources and looked at it a little bit more. While the file:FileName.fp7 works, I think FMSA has to work a little hard to find the file if its in a subfolder in the database directory. When I specified...

file:FolderName/FileName.fp7

it worked perfectly. (so far) I will keep this updated with any further issues.

jon

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