Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-17101

civicrm_api3_basic_get does not work for SQL operators on custom fields.

    Details

    • Documentation Required?:
      None
    • Funding Source:
      Contributed Code

      Description

      If you use the api to search on a custom field of a non-contact, and you use a sql operator like <=, you get an exception. E.g.:

      $result = civicrm_api3('Event', 'get', 'custom_2' => array('<=' => 'BBBB'));
      

      Results in an exception, that contains a query like this:

      Failure in api call for event get: DB Error: no such field
      SELECT (lots of fields I left out), civicrm_value_testeventgetc_1.testeventgetcustomfieldlte_1 as custom_1
      FROM civicrm_event a
      LEFT OUTER JOIN civicrm_value_testeventgetc_1 ON civicrm_value_testeventgetc_1.entity_id = a.id
      WHERE (a.testeventgetcustomfieldlte_1 <= "BBBB")
      LIMIT 25
      OFFSET 0

      The error is in the where clause. testeventgetcustomfieldlte_1 is a field of custom_1, not a field of a.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              johanv Johan Vervloet
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: