CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Query Alter hook?
Pages: [1]

Author Topic: Query Alter hook?  (Read 628 times)

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Query Alter hook?
June 12, 2011, 02:35:33 pm
Has anyone looked into how feasible a QUERY ALTER hook would be on smart groups/ saved searches? I've been happily hacking WHERE clauses directly into the table which are too complex to do using from end tools but now I really want to do one which includes 'HAVING' & 'GROUP BY' (to get contacts whose most recent contribution was within a date range)
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: Query Alter hook?
June 12, 2011, 06:02:39 pm
Well, if you really wanted to, I think you could find a way to translate the contract used for Query BAO's (eg CRM/Contribute/BAO/Query, CRM/Event/BAO/Query, CRM/Mailing/BAO/Query-- the last is one I recently contributed) into the conventions/format of a "hook". That would provide the model for query manipulation.

But I think the hook-implementation would need to exercise some discretion (i.e. you don't want to modify all queries -- only queries related to a particular smart group). The trick is figuring out what information the hook-implementation can use to activate itself.

I guess you could try to key off the group or saved-search ID, but that's going to pose two challenges: (1) the UX will be pretty brittle (2) the current codepaths are designed to build the same queries for "Smart Groups" (which have ID#s) and for "Advanced Search" (which doesn't have an ID#), so there could be some difficulty in reliably getting an ID#.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Query Alter hook?

This forum was archived on 2017-11-26.