Example #1
0
 /** Loads and returns an object that this object is linked to. 
  * $name       The name of the foreign object in the database.  For example, if the entry for the foreign 
  *             object was 'test_otherobject_id', the $name would be 'otherobject'. 
  * $extrainfo  If this is set, the key used will be test_otherobject_extrainfo_id. This is used when multiple
  *             references to a foreign table are required. */
 public function getForeignObject($name, $extrainfo = '')
 {
     if (!clsDB::isValidFieldName($name)) {
         throw new Exception(ERRORMSG_INVALID);
     }
     if (!clsDB::isValidFieldName($extrainfo)) {
         throw new Exception(ERRORMSG_INVALID);
     }
     $strForeignName = clsDB::toForeignName($name, $extrainfo);
     if (isset($this->arrForeignObjects[$strForeignName])) {
         return $this->arrForeignObjects[$strForeignName];
     } else {
         $foreignID = $this->get($strForeignName);
         $newDB = new clsDB($name, $foreignID);
         $this->arrForeignObjects[$strForeignName] = $newDB;
         return $newDB;
     }
 }