[FX.php List] Mixed search requests

Dale Bengston dbengston at preservationstudio.com
Wed Oct 25 14:04:55 MDT 2006


Hi Chris,

Whenever possible, I let PHP do the heavy lifting. As long as your  
initial found set (based on one criterion) is not a million records,  
it might be easier to walk the array looking for matches to the other  
criteria. I'd query FMP with the criterion that will start you out  
with the smallest record pool, and start from there.

Dale

On Oct 25, 2006, at 2:28 PM, Chris Bisgard wrote:

> Hello all,
>
> This question may reveal my inexperience with FileMaker queries and
> scripts, PHP, or databases in general, but here goes... I have a
> contacts database of arts organizations, and I want to be able to do a
> logical "OR" keyword search of three different fields (organization
> name, description, and category), and then optionally narrow the  
> results
> by one of three geographic locales AND optionally by one of seven
> artistic disciplines (exact matches). Because of FileMaker's inability
> to combine logical AND/OR search types, I am currently doing this by
> doing the initial keyword search, and then running scripts on the  
> found
> set to constrain first by locale and then by discipline. The AddParam
> statements for which scripts to run are determined conditionally based
> on POST data. Also, if keyword is left blank, it just does a Find All
> and then runs the scripts on that.
>
> This works fine for the first script (constrain by location), but not
> for the second (constraing by discipline). For some reason, the second
> script doesn't seem to be running after the first one? I'm not really
> sure what's happening. In any case, the results are that I get a
> successful keyword search that is then successfully constrained to the
> selected locale, but not constrained again by discipline.
>
> My question is, can I use a second instance of FX to query the SAME
> results for discipline, based on whether the user has included that in
> their criteria? Or is it better to just have a PHP script that walks
> through the results array and pulls out records containing the  
> requested
> discipline? My concern with that is that it will mess up my found  
> count,
> next/prev links, etc., unless I write some fancy code to deal with  
> those
> items... And I'm not sure if I know how to do that with an array,  
> in any
> case.
>
> Optionally, is it possible to pass user variables from PHP to a script
> in FileMaker, so that I could do both constrains dynamically in one
> script, based on user input? Or am I just making this harder than it
> needs to be?
>
> I hope this all makes sense... I'm tired and my vision is blurry.  
> Below
> is the code for the "search/script/script" model described in my first
> paragraph.
>
> And a big thanks to anyone who reads this and has any ideas.
>
> Chris Bisgard
> Information Technology Specialist
> Regional Arts & Culture Council
> 108 NW 9th Avenue, Suite 300
> Portland, Oregon 97209-3318
> cbisgard at racc.org
>
> ------ CODE HERE ------
>
> include_once("/inetpub/wwwroot/FX/FX.php");
> include_once("/inetpub/wwwroot/FX/server_data.php");
> include_once("/inetpub/wwwroot/FX/FMErrors.php");
>
> $search=new FX($serverIP,$webCompanionPort);
> $search->setDBData('ArtResources','web',$returnCount);
> $search->AddDBParam('-lop','or');
>
> if ($_POST['keyword'] != "") {
> 	$keyword = $_POST['keyword'];
> 	$search->AddDBParam('OrgName',$keyword,$op='cn');
> 	$search->AddDBParam('Description',$keyword,$op='cn');
> 	$search->AddDBParam('Category',$keyword,$op='cn');
> 	$search->AddDBParam('Discipline',$keyword,$op='cn');
> }
>
> // If the "Locale" option is set, run the appropriate script in
> FileMaker to constrain results by locale
> if ($_POST['geo'] != "") {
> 	$geo = $_POST['geo'];
> 	if ($geo == "Portland Metro") {
> 		$search->AddDBParam('-script.presort','Geo_PDXMetro');
> 	}
> 	elseif ($geo == "Oregon/Washington") {
> 		$search->AddDBParam('-script.presort','Geo_OrWash');
> 	}
> 	elseif ($geo == "National/International") {
> 		$search->AddDBParam('-script.presort','Geo_NatlIntl');
> 	}
> }
>
> // If the "Discipline" option is set, run the appropriate script in
> FileMaker to constrain results by discipline
> if ($_POST['discipline'] != "") {
> 	$discipline = $_POST['discipline'];
> 	if ($discipline == "Dance") {
> 		$search->AddDBParam('-script.presort','Dsp_Dance');
> 	}
> 	elseif ($discipline == "Film/Video/Media Arts") {
> 	
> $search->AddDBParam('-script.presort','Dsp_FilmVideoMedia');
> 	}
> 	elseif ($discipline == "Literary Arts") {
> 		$search->AddDBParam('-script.presort','Dsp_Literary');
> 	}
> 	elseif ($discipline == "Music") {
> 		$search->AddDBParam('-script.presort','Dsp_Music');
> 	}
> 	elseif ($discipline == "Theater") {
> 		$search->AddDBParam('-script.presort','Dsp_Theater');
> 	}
> 	elseif ($discipline == "Visual Arts") {
> 		$search->AddDBParam('-script.presort','Dsp_Visual');
> 	}
> 	elseif ($discipline == "Other") {
> 		$search->AddDBParam('-script.presort','Dsp_Other');
> 	}
> }
>
> // Decide whether to search by keyword or just find all records
> if ($keyword != "") {
> 	$searchResult=$search->FMFind();	
> }
> else {
> // Since no keyword present, find ALL records
> 	$searchResult=$search->FMFindAll();		
> }
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list



More information about the FX.php_List mailing list