March 18, 200817 yr 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 March 18, 200817 yr by Guest
March 20, 200817 yr Author 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
March 20, 200817 yr $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?
March 21, 200817 yr Author 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
March 21, 200817 yr 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 March 21, 200817 yr by Guest
March 22, 200817 yr Author 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
March 23, 200817 yr That code is anything but moot point. If its not working then something is wrong on a deep level.
March 23, 200817 yr Author Sorry, try http://141.209.36.46/somsite/ if it ever resolves to the local file just add the last backslash onto the name.
March 27, 200817 yr I'm having the same problem with periodic issues. See my post- Back button shows all records. Maybe it is just a Michigan thing!
April 1, 200817 yr Author 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
April 2, 200817 yr 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.
April 12, 200817 yr 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.
April 15, 200817 yr Author 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
April 20, 200817 yr Author 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
Create an account or sign in to comment