[FX.php List] Need Help With A Complex Query, This AND That OR This AND That...

Rich Aber raber at knightprinting.com
Mon Nov 14 11:27:49 MST 2005


Hello, I'm very new to FX.php, and need some help figuring out how to 
code a query.
I'm searching an FM database for records relating to Customers,
based on the Customer's ID, and only returning records that are 
'Active',
and omitting records that have a flag for 'Duplicate',
then sorting by a parameter such as 'JobNumber.'

This code accomplishes that task:
$searchName->AddDBParam('ID','1234');
$searchName->AddDBParam('Active','Active');
$searchName->AddDBParam('Dupes','x',$op="neq");
$searchName->AddSortParam('JobNumber','ascend');

However, I need to expand upon this, because we have some customers 
with multiple IDs.
I thought something like this might work:
$searchName->AddDBParam('ID','1234');
$searchName->AddDBParam('ID','5678');
$searchName->AddDBParam('Active','Active');
$searchName->AddDBParam('Dupes','x',$op="neq");
$searchName->AddSortParam('JobNumber','ascend');

But that code returns no results.

I then tried using the -lop operator, like this:
$searchName->AddDBParam('ID','1234');
$searchName->AddDBParam('-lop', 'or'); //Does this make all of the 
DBParams OR?!?!
$searchName->AddDBParam('ID','5678');
$searchName->AddDBParam('Active','Active');
$searchName->AddDBParam('Dupes','x',$op="neq");
$searchName->AddSortParam('JobNumber','ascend');

That code returns EVERYTHING in my database, regardless of 'CustID.'

How do I get the 'CustID' parameter to be logical OR,
and the other parameters to be logical AND?

I know in MySQL I could write a statement similar to:
SELECT ID, Active, Dupes, JobNumber FROM Jobs WHERE ID='1234' OR 
ID='5678' AND Active='Active' AND Dupes!='x';
...or something to that effect, but how would I do this with FX.php?

Any help would be greatly appreciated.

Thank you,

Richard Aber



More information about the FX.php_List mailing list