I think i have worked this out, here is what i have done incase anyone else runs into this.
Initially i tried simply putting an opening bracket into the field name where i wanted the grouping to start
$WADbSearch1->addComparison("(defaultcollectionname_rec","".$_GET['style'] ."","AND","=",0);
and where i wanted the grouping to end:
$WADbSearch1->addComparison("bcollectionname_rec)","".$_GET['style'] ."","OR","=",0);
this generated the following sql:
AND (artist_rec LIKE 'C%') AND ((defaultcollectionname_rec = 'Northern and 60s') OR (acollectionname_rec = 'Northern and 60s') OR (bcollectionname_rec) = 'Northern and 60s')
Although this seems to work the closing bracket appears after the fieldname not after the full statement.
I dont like malformed code so i went back to the drawing board and came up with the soloution...
I edited the helper.php file and added the following function (just before the create comparison function)
function addcloseGrouping() {
$this->whereClause=$this->whereClause.")";
}
i changed the code on my page and applied an opening bracket to the fieldname of where i wanted the grouping to start, after the last field where i want the grouping to end i added a call to the new function closeGrouping:
//comparison list additions
$WADbSearch1->addComparison("artist_rec","".$currentAlpha ."","AND","Begins With",0);
$WADbSearch1->addComparisonFromEdit("formatname_rec","45s","AND","=",0);
$WADbSearch1->addComparison("(defaultcollectionname_rec","".$_GET['style'] ."","AND","=",0);
$WADbSearch1->addComparison("acollectionname_rec","".$_GET['style'] ."","OR","=",0);
$WADbSearch1->addComparison("bcollectionname_rec","".$_GET['style'] ."","OR","=",0);
$WADbSearch1->closeGrouping();
my final sql statement that is generated looks like this:
AND (artist_rec LIKE 'C%') AND ((defaultcollectionname_rec = 'Northern and 60s') OR (acollectionname_rec = 'Northern and 60s') OR (bcollectionname_rec = 'Northern and 60s'))
which is correctly formatted code and seems to work as expected.
It would be nice if someone from webassist could comment on this and let me know if here is a better or easier way of doing this. or if this method is sufficient.