2

I want to get all the contribution table entries as a list which are equivalent to a given ID.

My contribution table has 4 entries and the contact ID for all the four contribution is 2.

I'm using the below method to get the details, but which takes the given ID as contactID and return the entries when contactID = contributionID..

foreach ($values as $key => $value){
        
        $contributionID = $values[$key]; //contribution IDs are 1,2,3,4,5
        
        // get the details for all selected contacts
        list($contributionDetails) = CRM_Utils_Token::getTokenDetails(array($contributionID),
          $this->_returnProperties,
          NULL, NULL, FALSE,
          $this->_allTokens
        );

Mean this only returns a row where contribution ID = contact ID = 2..but i want to get all the raw where contribution id is equal to 1,2,3,4 and 5.. how should i get it?

Thanks in advance!

2
  • I'm not understanding what you want to do. What's the bigger picture?
    – Aidan
    Jul 15, 2020 at 10:09
  • @Aidan I'm searchiing a method to input contribution ID and return all the token details..is there any particular class and a method to perform it?
    – safron
    Jul 15, 2020 at 12:48

1 Answer 1

3

You can use CRM_Contribute_BAO_Contribution::getContributionTokenValues() function to get details of contribution based on contribution id.

To get all data of contribution you can use api

$contributionData = civicrm_api3('Contribution', 'getsingle', ['id' => $contributionId]);
8
  • Thank you for your answer.for the getContributionTokenValues() function i want to pass the contribution id and the parameter na? but i want to retrieve all the values based on only the contribution ID.is there any particular function to get it?
    – safron
    Jul 15, 2020 at 14:52
  • yes you need to pass contribution id and other params. To get the values based on contribution id you can use api(updated my answer with api call) Jul 15, 2020 at 15:02
  • Thank you for your answer.. do you mind if i ask another question? is there any in-build API like you stated above to retrieve data from a view?
    – safron
    Jul 23, 2020 at 9:39
  • shoot please.... Jul 23, 2020 at 11:43
  • Thanks..the question is i want retrieve data from a view. Is there any inbuilt API available for it ? I feel running a SQL then taken the result, fetching it and assigning into another array is less efficient. so I'm finding an alternative way
    – safron
    Jul 23, 2020 at 11:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.