[FX.php List] Query question
Dale Bengston
dbengston at preservationstudio.com
Thu Jan 25 17:04:40 MST 2007
I second Dan's recommendation to get a found set with the first three
parameters and filter for the catalog ids. This will be much faster
than running scripts or constricting a found set on the FMP side.
My approach:
$catIDs - 'AB001 AB002 AB003';
$catArray = split(' ', $catIDs); //or some other way of obtaining the
catalog ids as an array
$filteredRecs = array();
foreach ($result['data'] as $key => $value)
{
if (in_array($value['catID'][0], $catIDs))
{
$filteredRecs[$key] = $value;
}
}
This version turns $filteredRecs into a subset of $result['data']
that matches your list of catalogs. You could choose to prune the FX
data while you're filtering, if that serves the purpose.
Dale
On Jan 25, 2007, at 5:21 PM, DC wrote:
> my advice... do the first query (city, state, zip). then take the
> FX result and run it through a foreach() checking the catalog field
> for your AB001,AB002 etc strings.
>
> untested code:
> $cat_num="AB001 AB002 AB003";
> $arr= array();
> foreach ($FX_RESULT_DATA as $rec) {
> // check each record's catalog field
> // assume one catalog entry per record (ie. not multiline)
> // space at front allows us to rely on zero return value ==FALSE
> if (strpos(' '. $cat_num, $rec['catalog'][0])) {
> $arr[] = $rec['catalog'][0]; // add to new array
> }
> }
>
> if you have a multiline catalog field you'll have to do some extra
> steps to get the comparison right.
>
> HTH,
> dan
>
> Bob Patin had written:
>> I can't believe I've not had to do this type of search before:
>> I need to search 5 or more fields; in one of the fields, I need to
>> search for 1 or more different catalog numbers. So a search would
>> be like this:
>> CITY -- 1 value here
>> STATE - 1 value here
>> ZIP - 1 value here
>> CATALOG NUMBER - could be a bunch of different cat. numbers
>> I'd thought that I could just concatenate the catalog numbers like
>> this:
>> $cat_num=AB001 AB002 AB003 ... and so on
>> and then search the catalog_number field using a single line
>> AddDBParam('cat_num',$cact_num);
>> But this doesn't work right. if I add an OR conditional, doesn't
>> it apply to the whole query?
>> How do I search for this:
>> (these first 3 must match)
>> Nashville
>> TN
>> 37211
>> plus, it must contain 1 of these catalog numbers:
>> AB001 or AB002 I know this is simple, but I can't remember how
>> this is done...
>> Thanks,
>> Bob Patin
>> bob at patin.com
>> _______________________________________________
>> FX.php_List mailing list
>> FX.php_List at mail.iviking.org
>> http://www.iviking.org/mailman/listinfo/fx.php_list
> _______________________________________________
> 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