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) »
  • Support »
  • Using CiviCRM (Moderator: Dave Greenberg) »
  • Custom Search - How to not show all records from the SQL query
Pages: [1]

Author Topic: Custom Search - How to not show all records from the SQL query  (Read 1239 times)

SarahG (FountainTribe)

  • Ask me questions
  • ****
  • Posts: 782
  • Karma: 29
  • CiviCRM version: 4.4.7
  • CMS version: Drupal 6, Drupal 7
  • MySQL version: 5.5
  • PHP version: 5.3
Custom Search - How to not show all records from the SQL query
May 25, 2009, 06:22:55 pm
I have a custom search that is working well. But I want to improve it by allowing an additional selection criteria. But the problem is I won't know if the record meets the criteria until after the data comes back from the database and I have called my PHP function.   I already am using the "alterRow" function to alter the contents of certain cells. But how do I exclude certain rows?

For example, the sql query returns 100 records. But I only want to display 30 records to the screen.  ( the other 70 do not meet the criteria. ) And no, I cannot put the criteria in the SQL WHERE clause because I need to need to call a PHP function to know what to exclude.  Also how will this impact the "count" function?   

Thanks
Did I help you? Please donate to the Civi-Make-It-Happen campaign  CiviCRM for mobile devices! 

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Custom Search - How to not show all records from the SQL query
May 25, 2009, 06:29:01 pm

the easiest option right now would be to use a temp table. Basically store all your results in the temp table. filter the temp table as needed using php function and delete rows etc. the count and sql are simple count/select on this temp table

check CRM/Contact/Form/Search/Custom/PriceSet.php

for an example of using a temp table

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM (Moderator: Dave Greenberg) »
  • Custom Search - How to not show all records from the SQL query

This forum was archived on 2017-11-26.