コード例 #1
0
 /**
  * Deletes the planned transaction identified by $plannedTransactionId.
  * 
  * @param $plannedTransactionId integer The id of the planned transaction to delete.
  * @throws BadgerException If $plannedTransactionId is unknown to the DB.
  */
 public function deletePlannedTransaction($plannedTransactionId)
 {
     $plannedTransactionId = PlannedTransaction::sanitizeId($plannedTransactionId);
     if (isset($this->plannedTransactions[$plannedTransactionId])) {
         unset($this->plannedTransactions[$plannedTransactionId]);
     }
     $sql = "DELETE FROM planned_transaction\n\t\t\t\tWHERE planned_transaction_id = {$plannedTransactionId}";
     $dbResult =& $this->badgerDb->query($sql);
     if (PEAR::isError($dbResult)) {
         //echo "SQL Error: " . $dbResult->getMessage();
         throw new BadgerException('Account', 'SQLError', $dbResult->getMessage());
     }
     if ($this->badgerDb->affectedRows() != 1) {
         throw new BadgerException('Account', 'UnknownPlannedTransactionId', $plannedTransactionId);
     }
 }
コード例 #2
0
 /**
  * Deletes the planned transaction identified by $plannedTransactionId.
  * 
  * @param $plannedTransactionId integer The id of the planned transaction to delete.
  * @throws BadgerException If $plannedTransactionId is unknown to the DB.
  */
 public function deletePlannedTransaction($plannedTransactionId)
 {
     $plannedTransactionId = PlannedTransaction::sanitizeId($plannedTransactionId);
     $sql = "SELECT transferal_transaction_id \r\n\t\t\tFROM planned_transaction\r\n\t\t\tWHERE planned_transaction_id = {$plannedTransactionId}";
     $dbResult =& $this->badgerDb->query($sql);
     if (PEAR::isError($dbResult)) {
         throw new BadgerException('Account', 'SQLError', "SQL: {$sql}\n" . $dbResult->getMessage());
     }
     $dbResult->fetchInto($row, DB_FETCHMODE_ASSOC);
     $transferalId = $row['transferal_transaction_id'];
     $sql = "DELETE FROM planned_transaction\n\t\t\t\tWHERE planned_transaction_id = {$plannedTransactionId}\r\n\t\t\t\t\tOR transferal_transaction_id = {$plannedTransactionId}";
     //		$transferalId = null;
     //		if (
     //			!is_null($tmp = $this->getPlannedTransactionById($plannedTransactionId))
     //			&& !is_null($tmp2 = $tmp->getTransferalTransaction())
     //		) {
     //			$transferalId = $tmp2->getId();
     //			$sql .= " OR planned_transaction_id = $transferalId";
     //		}
     $dbResult =& $this->badgerDb->query($sql);
     if (PEAR::isError($dbResult)) {
         throw new BadgerException('Account', 'SQLError', "SQL: {$sql}\n" . $dbResult->getMessage());
     }
     if ($this->badgerDb->affectedRows() < 1) {
         throw new BadgerException('Account', 'UnknownPlannedTransactionId', $plannedTransactionId);
     }
     $sql = "DELETE FROM finished_transaction\n\t\t\t\t\tWHERE planned_transaction_id = {$plannedTransactionId}";
     if (!is_null($transferalId)) {
         $sql .= " OR planned_transaction_id = {$transferalId}";
     }
     $dbResult =& $this->badgerDb->query($sql);
     if (PEAR::isError($dbResult)) {
         throw new BadgerException('Account', 'SQLError', "SQL: {$sql}\n" . $dbResult->getMessage());
     }
     //We should clean up the TransferalTransaction out of the corresponding Account object, but this is complex
     if (isset($this->plannedTransactions[$plannedTransactionId])) {
         unset($this->plannedTransactions[$plannedTransactionId]);
     }
 }