July 12, 201213 yr $compoundFind =& $fm->newCompoundFindCommand('Accounts'); $findreq1 =& $fm->newFindRequest('Accounts'); $findreq2 =& $fm->newFindRequest('Accounts'); $findreq1->addFindCriterion('acctype', 'User'); $findreq2->addFindCriterion('squestion', '1'); $compoundFind->add(1,$findreq1); $compoundFind->add(2,$findreq2); $result = $compoundFind->execute(); When i use the above compoundfind, I found all the records where the acctype=User also squestion=1 But i need the the records where acctype=User and squestion=1 (refer attached image: I need 2 records only which is marked in green color) Please help me to alter the above find code to attain my solution
July 12, 201213 yr Compound Find requests perform an or search (Criterion1 OR Criterion2). You only need the normal newFindCommand to perform an and search (Criterion1 AND Criterion2): $findreq =& $fm->newFindCommand('Accounts'); $findreq->addFindCriterion('acctype', 'User'); $findreq->addFindCriterion('squestion', '1'); $result = $findreq->execute();
July 16, 201213 yr Author Thank u doughemi, With this same case how do i get the records where the acctype="User" and acctype="Family" ? That means i have to filter more than one data from the single column. Thanks your valuable reply and valuable time
July 16, 201213 yr In this case, you are looking to find records in which acctype="User" OR acctype ="Family". (it is impossible in this instance to have a record in which acctype contains both "User" AND "Family"). Thus, you would use the Compound Find structure: $compoundFind =& $fm->newCompoundFindCommand('Accounts'); $findreq1 =& $fm->newFindRequest('Accounts'); $findreq2 =& $fm->newFindRequest('Accounts'); $findreq1->addFindCriterion('acctype', 'User'); $findreq2->addFindCriterion('acctype', 'Family'); $compoundFind->add(1,$findreq1); $compoundFind->add(2,$findreq2); $result = $compoundFind->execute(); I would recommend that you research "Boolean AND and OR operators" to build your understanding of these important tools. These operators have much more specific definitions than the common usage of the English words they are based on. Now, if you were conducting a search for records which have either "User" or "Family" in the acctype field and at the same time have 1 in the squestion field, you would have to expand the Compound Find structure: $compoundFind =& $fm->newCompoundFindCommand('Accounts'); $findreq1 =& $fm->newFindRequest('Accounts'); $findreq2 =& $fm->newFindRequest('Accounts'); $findreq1->addFindCriterion('acctype', 'User'); $findreq1->addFindCriterion('squestion', '1'); $findreq2->addFindCriterion('acctype', 'Family'); $findreq2->addFindCriterion('squestion', '1'); $compoundFind->add(1,$findreq1); $compoundFind->add(2,$findreq2); $result = $compoundFind->execute();
Create an account or sign in to comment