Skip to content
This repository has been archived by the owner on Feb 24, 2020. It is now read-only.

Error when traying to retrieve participants / gender #174

Open
magnolia61 opened this issue Jun 23, 2019 · 0 comments
Open

Error when traying to retrieve participants / gender #174

magnolia61 opened this issue Jun 23, 2019 · 0 comments

Comments

@magnolia61
Copy link

magnolia61 commented Jun 23, 2019

I was trying to retrieve all male participant of an event using api4 but this results in an error.

$participants = \Civi\Api4\Participant::get()
  ->addWhere('status_id', '=', 1)
  ->addWhere('event_id', '=', 148)
  ->addWhere('participant_contact.gender_id', '=', 2)
  ->setCheckPermissions(false)
  ->execute();
foreach ($participants as $participant) {
  // do something
}

But in the api explorer I get the following message:

{
  "error_code": 0,
  "error_message": "DB Error: no such field"
}

And the CiviCRM error log shows this:

FROM civicrm_participant a
LEFT JOIN `civicrm_contact` `participant_contact` ON a.participant_contact_id =  participant_contact.id
WHERE (`a`.`status_id` = "1") AND (`a`.`event_id` = "148") AND (`participant_contact`.`gender_id` = "2")
 [nativecode=1054 ** Unknown column 'a.participant_contact_id' in 'on clause']

I believe a wrong field is used in the join query (participant_contact_id instead of contact_id).
In the table civicrm_participant the field contact_id should be used I guess.

Am I the first to encounter this and is this really a bug?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant