close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Data assist search, need to group search criteria

Thread began 3/01/2012 4:56 am by Base5 Designs | Last modified 3/02/2012 3:27 am by Dave Buchholz | 1210 views | 3 replies |

Base5 Designs

Data assist search, need to group search criteria

Hi there

I have a table with a list of records which i am trying to filter using the database search

my fields are (not these actual names just so you can see what data i have)

artist
recordType
defaultCollection
collectionAside
collectionBside

the search i am trying to do is as follows:

artist name begins with a specific letter (from a get variable)
AND
record type = specific criteria (from a get variable)

in addition to the above

i need to check if ANY of the following match

defaultCollection = specific criteria (from a get variable)
OR
collectionAside= specific criteria (from a get variable)
OR
collectionBside = specific criteria (from a get variable)

if i was doing this manually i would simply have AND then the following in brackets:

AND (defaultCollection = * or collectionAside = * or collectionBside = *)

is there a way to do this with he database search, or can i edit the code created to achive this?

thanks for your time

Sign in to reply to this post

Base5 Designs

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)

php:
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:

php:
//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:

php:
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.

Sign in to reply to this post

Jason ByrnesWebAssist

This likes like it should work just fine.

DataAssist Search does not offer a way of creating groupings like this, but your code edit looks sound.

Sign in to reply to this post

Dave BuchholzBeta Tester

What a great solution, thanks for posting

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...