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 »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Left Joins - kinda deep in though
Pages: [1]

Author Topic: Left Joins - kinda deep in though  (Read 699 times)

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Left Joins - kinda deep in though
October 11, 2010, 09:32:58 pm
I tried passing in a contribution_id to participant/get & got all the participant records for that contact

The cut down version of the query is this

Quote
SELECT DISTINCT (
contact_a.id
) AS contact_id, contact_a.sort_name AS `sort_name`
FROM civicrm_contact contact_a
LEFT JOIN civicrm_participant ON civicrm_participant.contact_id = contact_a.id
LEFT JOIN civicrm_contribution ON civicrm_contribution.contact_id = contact_a.id

INNER JOIN civicrm_event ON civicrm_participant.event_id = civicrm_event.id
WHERE (
civicrm_contribution.id =2358
AND civicrm_contribution.is_test =0
)
LIMIT 0 , 30

If it were this it would return the correct result

Quote
SELECT DISTINCT (
contact_a.id
) AS contact_id, contact_a.sort_name AS `sort_name`
FROM civicrm_contact contact_a
LEFT JOIN civicrm_participant ON civicrm_participant.contact_id = contact_a.id
LEFT JOIN civicrm_contribution ON civicrm_contribution.contact_id = contact_a.id

INNER JOIN civicrm_event ON civicrm_participant.event_id = civicrm_event.id
WHERE (
civicrm_contribution.id =2358
AND civicrm_contribution.is_test =0
)
LIMIT 0 , 30

But of course this query is being generated deep in the bowels of the code so I presume that lots of other things expect it to work just the way it does....
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

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Left Joins - kinda deep in though
October 11, 2010, 09:47:11 pm
Looks like my work around will be to do contribution get like this & then participant get

civicrm/contribution/search&return[participant_id]=1&return[contribution_id]=1&contribution_id=28
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

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Left Joins - kinda deep in though

This forum was archived on 2017-11-26.