Example #1
0
 /**
  * Used to set the OIDs of the related objects.  Pass a two-item array of OIDs, the first
  * one being the left object OID, the second being the right.
  *
  * @param array $OIDs
  *
  * @since 1.0
  *
  * @throws Alpha\Exception\IllegalArguementException
  */
 public function setValue($OIDs)
 {
     try {
         $this->leftID->setValue($OIDs[0]);
         $this->rightID->setValue($OIDs[1]);
     } catch (\Exception $e) {
         throw new IllegalArguementException('Array value passed to setValue is not valid [' . var_export($OIDs, true) . '], array should contain two OIDs');
     }
 }
Example #2
0
 /**
  * Loads all of the items for the given parent DEnum ID.
  *
  * @param int $EnumID The ID of the parent DEnum object.
  *
  * @return array
  *
  * @since 1.0
  *
  * @throws Alpha\Exception\AlphaException
  */
 public function loadItems($EnumID)
 {
     $config = ConfigProvider::getInstance();
     $this->DEnumID->setValue($EnumID);
     $sqlQuery = 'SELECT OID FROM ' . self::TABLE_NAME . ' WHERE DEnumID = \'' . $EnumID . '\';';
     $provider = ActiveRecordProviderFactory::getInstance($config->get('db.provider.name'), $this);
     try {
         $result = $provider->query($sqlQuery);
     } catch (CustomQueryException $e) {
         throw new AlphaException('Failed to load objects, error is [' . $e->getMessage() . ']');
         return array();
     }
     // now build an array of objects to be returned
     $objects = array();
     $count = 0;
     foreach ($result as $row) {
         $obj = new self();
         $obj->load($row['OID']);
         $objects[$count] = $obj;
         ++$count;
     }
     return $objects;
 }