Пример #1
0
 /**
  * Create a update object and return it.
  *
  * <code>
  * $options = array(
  *     "project_id" => 1
  * );
  *
  * $updates   = new Crowdfunding\Updates\Updates(\JFactory::getDbo());
  * $updates->load($options);
  *
  * $updateId = 1;
  * $update = $updates->getUpdate($updateId);
  * </code>
  *
  * @param int $id Update ID.
  *
  * @throws \UnexpectedValueException
  *
  * @return null|Update
  */
 public function getUpdate($id)
 {
     if (!$id) {
         throw new \UnexpectedValueException(\JText::_('LIB_CROWDFUNDING_INVALID_UPDATE_ID'));
     }
     $update = null;
     foreach ($this->items as $item) {
         if ((int) $id === (int) $item['id']) {
             $update = new Update($this->db);
             $update->bind($item);
             break;
         }
     }
     return $update;
 }
Пример #2
0
 /**
  * Return the updates as array with objects.
  *
  * <code>
  * $options = array(
  *     "ids" => array(1,2,3,4,5)
  * );
  *
  * $updates   = new Crowdfunding\Update\Updates(\JFactory::getDbo());
  * $updates->load($options);
  *
  * $updates = $updates->getUpdates();
  * </code>
  *
  * @return array
  */
 public function getUpdates()
 {
     $results = array();
     $i = 0;
     foreach ($this->items as $item) {
         $update = new Update($this->db);
         $update->bind($item);
         $results[$i] = $update;
         $i++;
     }
     return $results;
 }