0

I have created below hook for trigger some values in my table.

Here how to get source table values that are being updated or inserted

function history_civicrm_triggerInfo(&$info, $tableName) {
  $sourceTable = 'civicrm_membership_log';

  $sql = "
    INSERT INTO `civicrm`.`civicrm_membershipperiod` 
(`id`, `membership_id`, `start_date`, `end_date`) VALUES (NULL, '1', '2017-07-03', '2018-07-03');";


  $info[] = array(
      'table' => $sourceTable,
      'when' => 'AFTER',
      'event' => 'INSERT',
      'sql' => $sql,
  );
  $info[] = array(
      'table' => $sourceTable,
      'when' => 'AFTER',
      'event' => 'UPDATE',
      'sql' => $sql,
  );
}

Based on the source table value I have to rewrite the query $sql

1

I'm not familiar with this hook, but the manual seems to suggest that OLD.column_name and NEW.column_name can be used to access old and new values respectively.

  • You are correct its working now; – ManiMuthuPandi Jul 6 '17 at 18:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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