Jon Crain Posted March 18, 2008 Posted March 18, 2008 (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 March 18, 2008 by Guest
Jon Crain Posted March 20, 2008 Author Posted March 20, 2008 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
Genx Posted March 20, 2008 Posted March 20, 2008 $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?
Jon Crain Posted March 21, 2008 Author Posted March 21, 2008 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
Genx Posted March 21, 2008 Posted March 21, 2008 (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 March 21, 2008 by Guest
Jon Crain Posted March 22, 2008 Author Posted March 22, 2008 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
Genx Posted March 23, 2008 Posted March 23, 2008 That code is anything but moot point. If its not working then something is wrong on a deep level.
Genx Posted March 23, 2008 Posted March 23, 2008 141.209.36.46 - goes to IWP Adding somsite resolves to a local address.
Jon Crain Posted March 23, 2008 Author Posted March 23, 2008 Sorry, try http://141.209.36.46/somsite/ if it ever resolves to the local file just add the last backslash onto the name.
Thomas Ledbetter Posted March 27, 2008 Posted March 27, 2008 I'm having the same problem with periodic issues. See my post- Back button shows all records. Maybe it is just a Michigan thing!
Jon Crain Posted April 1, 2008 Author Posted April 1, 2008 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
Genx Posted April 2, 2008 Posted April 2, 2008 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.
Jon Crain Posted April 10, 2008 Author Posted April 10, 2008 fmnet:/141.209.36.46/CCCalendar_SchedulingEdition Jon
Genx Posted April 12, 2008 Posted April 12, 2008 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.
Jon Crain Posted April 15, 2008 Author Posted April 15, 2008 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
Genx Posted April 20, 2008 Posted April 20, 2008 John when you get a chance let us know if its still being consistent. Cheers.
Jon Crain Posted April 20, 2008 Author Posted April 20, 2008 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
Recommended Posts
This topic is 6398 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 accountSign in
Already have an account? Sign in here.
Sign In Now