/** * Create a transaction object and return it. * * <code> * $options = array( * "ids" => array(1,2,3,4,5) * ); * * $transactions = new Crowdfunding\Transaction\Transactions(\JFactory::getDbo()); * $transactions->load($options); * * $transactionId = 1; * $transaction = $transactions->getTransaction($transactionId); * </code> * * @param int|string $id Transaction ID. * * @return null|Transaction */ public function getTransaction($id) { if (!$id) { throw new \UnexpectedValueException(\JText::_('LIB_CROWDFUNDING_INVALID_TRANSACTION_ID')); } $transaction = null; foreach ($this->items as $item) { if ((int) $id === (int) $item['id']) { $transaction = new Transaction($this->db); $transaction->bind($item); break; } } return $transaction; }
/** * Return the transactions as array with objects. * * <code> * $options = array( * "ids" => array(1,2,3,4,5) * ); * * $transactions = new Crowdfunding\Transactions(\JFactory::getDbo()); * $transactions->load($options); * * $items = $transactions->getTransactions(); * </code> * * @return array */ public function getTransactions() { $results = array(); $i = 0; foreach ($this->items as $item) { $transaction = new Transaction($this->db); $transaction->bind($item); $results[$i] = $transaction; $i++; } return $results; }