/** * Detach a contribution from a transaction * * @param int $trans_id Transaction identifier * @param int $contrib_id Contribution identifier * * @return boolean */ public static function unsetTransactionPart($trans_id, $contrib_id) { global $zdb; try { //first, we check if contribution is part of transaction $c = new Contribution((int) $contrib_id); if ($c->isTransactionPartOf($trans_id)) { $update = $zdb->update(self::TABLE); $update->set(array(Transaction::PK => null))->where(self::PK . ' = ' . $contrib_id); $zdb->execute($update); return true; } else { Analog::log('Contribution #' . $contrib_id . ' is not actually part of transaction #' . $trans_id, Analog::WARNING); return false; } } catch (\Exception $e) { Analog::log('Unable to detach contribution #' . $contrib_id . ' to transaction #' . $trans_id . ' | ' . $e->getMessage(), Analog::ERROR); return false; } }