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 »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Search Builder Error
Pages: [1]

Author Topic: Search Builder Error  (Read 1239 times)

josue

  • I post occasionally
  • **
  • Posts: 81
  • Karma: 7
    • PTP
  • CiviCRM version: 3.4.4, 4.1.1
  • CMS version: Drupal 6.24, Drupal 7.12
  • MySQL version: 5.0
  • PHP version: 5.2
Search Builder Error
May 13, 2011, 01:00:35 pm
hey folks,

in doing a training today we tried to find contacts with no street address but with a state filled in.

tried this on the drupal demo site:

Individual -> State -> IS NOT NULL

Results:

Code: [Select]
Database Error Code: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND contact_a.contact_type IN ('Individual') ) ) AND (contact_a.is_deleted = 0' at line 1, 1064
Additional Details:

Array
(
    [callback] => Array
        (
            [0] => CRM_Core_Error
            [1] => handle
        )

    [code] => -2
    [message] => DB Error: syntax error
    [mode] => 16
    [debug_info] => SELECT DISTINCT UPPER(LEFT(contact_a.sort_name, 1)) as sort_name  FROM civicrm_contact contact_a LEFT JOIN civicrm_address ON ( contact_a.id = civicrm_address.contact_id AND civicrm_address.is_primary = 1 ) LEFT JOIN civicrm_state_province ON civicrm_address.state_province_id = civicrm_state_province.id  WHERE  (  (  AND contact_a.contact_type IN ('Individual') )  )  AND (contact_a.is_deleted = 0)     [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND contact_a.contact_type IN ('Individual') )  )  AND (contact_a.is_deleted = 0' at line 1]
    [type] => DB_Error
    [user_info] => SELECT DISTINCT UPPER(LEFT(contact_a.sort_name, 1)) as sort_name  FROM civicrm_contact contact_a LEFT JOIN civicrm_address ON ( contact_a.id = civicrm_address.contact_id AND civicrm_address.is_primary = 1 ) LEFT JOIN civicrm_state_province ON civicrm_address.state_province_id = civicrm_state_province.id  WHERE  (  (  AND contact_a.contact_type IN ('Individual') )  )  AND (contact_a.is_deleted = 0)     [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND contact_a.contact_type IN ('Individual') )  )  AND (contact_a.is_deleted = 0' at line 1]
    [to_string] => [db_error: message="DB Error: syntax error" code=-2 mode=callback callback=CRM_Core_Error::handle prefix="" info="SELECT DISTINCT UPPER(LEFT(contact_a.sort_name, 1)) as sort_name  FROM civicrm_contact contact_a LEFT JOIN civicrm_address ON ( contact_a.id = civicrm_address.contact_id AND civicrm_address.is_primary = 1 ) LEFT JOIN civicrm_state_province ON civicrm_address.state_province_id = civicrm_state_province.id  WHERE  (  (  AND contact_a.contact_type IN ('Individual') )  )  AND (contact_a.is_deleted = 0)     [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND contact_a.contact_type IN ('Individual') )  )  AND (contact_a.is_deleted = 0' at line 1]"]
)

seems like a bug, no?

--josue

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: Search Builder Error
May 14, 2011, 02:05:17 am
Seems like a bug indeed, can you file an issue on the Issue Tracker?
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

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: Search Builder Error
May 14, 2011, 11:25:45 am

Would be most helpful if u'll can investigate and submit a patch.

Search builder has not been updated/maintained for some time and we do not have the resources to do so. Ideally we'd love it if a group from the community organizes and helps improve / upgrade / make it more full featured. Quite a few people find it useful, so there is interest in it

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

josue

  • I post occasionally
  • **
  • Posts: 81
  • Karma: 7
    • PTP
  • CiviCRM version: 3.4.4, 4.1.1
  • CMS version: Drupal 6.24, Drupal 7.12
  • MySQL version: 5.0
  • PHP version: 5.2
Re: Search Builder Error
May 16, 2011, 02:15:42 pm
i will troubleshoot this further and see if i can understand what is the actual problem.

i think civicrm needs to offer the ability to do IS NULL and IS NOT NULL searches. that is the main reason i use the Search Builder. would be happy to do it some other way, if that were possible.

PTP is developing some custom searches, for the Engagement Index and some more advanced fundraising ones. i am starting to investigate the extension mechanism as a way to contribute them back.

maybe along the way i can get some of our folks to think about more generic searching, and even propose something for the Search Builder.

--josue


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: Search Builder Error
May 16, 2011, 04:15:50 pm

Yep, agreed that having more powerful search with various other operators is a good thing and something the project needs.

Views2 (and Views3) are far more sophisticated with what can be done with Civi Data, and hence are much better search builders (IMO). They also get a ton of love and care from a much larger community :) The Civi integration with Views2/3 is quite complete (and getting better with every release). IMO, it is a lot more powerful than search builder today

The one big thing that this integration is missing is the link to the various "tasks/actions" that CiviCRM performs (i.e. export contacts, send an email, add to group etc). Would be great if we can figure out how to integrate a "views" query with the rest of the civi framework. I do think it is doable, just a matter of someone spending some time and energy figuring out the best way to do so

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

malks

  • I post occasionally
  • **
  • Posts: 81
  • Karma: 7
  • CiviCRM version: 3.4.x 4.x
  • CMS version: Drupal 6.22
  • MySQL version: 5.1.x
  • PHP version: 5.3.x
Re: Search Builder Error
May 29, 2011, 07:28:34 pm
Sorry if I'm hijacking a thread, but I hit the issue where users couldn't do an "IS NOT NULL" (they wanted organisations without a fax number) and while the error doesn't appear in the latest demo, the search continues not to work.

I'm happy to spend time on getting this to work or working towards something better but would need a bit of direction to get going.  For example, is going down the views path the best option?  While I think views is a great piece of kit, I don't necessarily think that it's the same use case as what search builder does, even if you expose a standard set of filters.  And doesn't this leave the Joomla users out in the cold? (which is fine with me btw as I'm purely a Drupal person :))

Having just typed that, I think the way forward if using views is to provide a default view (a view created in code) that would replace the search functionality.  As Donald states then the major missing piece is the tasks/action integration, which to be honest is why my users are doing a search in the first place.  I've also found the tasks/action bit, and writing custom tasks/actions, one of the best integration points for new function.  You could use views bulk operations to provide a similar function I think, but then I also think that this view would have to live outside of Civi because of clashes with jQuery etc.

Is this the right place to have this discussion btw?

Malks.

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: Search Builder Error
May 29, 2011, 07:54:52 pm

If the views3 approach works for you, i would go down that path and see if you can build the search builder as a view etc. If you can make progress using views bulk operations and action/tasks that would be great

I think it would benefit the community a lot if someone got some code working using the above approach

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

malks

  • I post occasionally
  • **
  • Posts: 81
  • Karma: 7
  • CiviCRM version: 3.4.x 4.x
  • CMS version: Drupal 6.22
  • MySQL version: 5.1.x
  • PHP version: 5.3.x
Re: Search Builder Error
May 29, 2011, 08:00:15 pm
OK, I'm going to explore that option then.  It kinda dovetails into something else I was playing with, i.e. creating new Rules that integrate with Civi (mainly around Event workflows, i.e. when someone is marked as attending an event, generate an activity to follow up etc.)

I have a Drupal 7 install that I can play with so will get Civi/Views on it and see what I can come up with.

My biggest concern with this though is how are you envisaging a view to have the enter more search criteria function?

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: Search Builder Error
May 30, 2011, 08:27:43 pm

I'm not really envisaging anything specific, since i dont consider myself as being an expert in views :)

I think pushing in that direction and seeing what is possible and doable is a good starting point

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

malks

  • I post occasionally
  • **
  • Posts: 81
  • Karma: 7
  • CiviCRM version: 3.4.x 4.x
  • CMS version: Drupal 6.22
  • MySQL version: 5.1.x
  • PHP version: 5.3.x
Re: Search Builder Error
May 30, 2011, 09:19:39 pm
hmm, I'm not so convinced.  Views is good for returning lists of data, which could be construed as search results, but the interface for changing the criteria, beyond exposing filters, isn't for the faint hearted.  And the filters exposed don't have the expressiveness of the search builder IMHO.  Happy to discuss where you see views slotting into the bigger picture and spending some time working through it, but is it for a separate thread?  Where should that thread go?  I have now officially hijacked this thread.

Getting back to the OP's topic, the IS NOT NULL function doesn't work (at least for phone) on http://drupal.demo.civicrm.org/ at the moment even though no error is raised.  e.g. (and this is a search a user wanted), show me individuals who have a fax number, show me contacts where Individual->Phone->Work->Fax->IS NOT NULL.  If you do this you get records that don't have a work fax defined.  Am I doing the query right?  I'm going to poke around and see if I can work out what is going on but guidance would be welcome.

malks

  • I post occasionally
  • **
  • Posts: 81
  • Karma: 7
  • CiviCRM version: 3.4.x 4.x
  • CMS version: Drupal 6.22
  • MySQL version: 5.1.x
  • PHP version: 5.3.x
Re: Search Builder Error
May 30, 2011, 09:40:52 pm
Oh, and the error on state occurs too... will look in to it while I'm at it.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Search Builder Error

This forum was archived on 2017-11-26.