/** * Static Helper Method to Create using PK arguments * You must pass in the PK arguments on an object to load, or leave it blank to create a new one. * If you want to load via QueryString or PathInfo, use the CreateFromQueryString or CreateFromPathInfo * static helper methods. Finally, specify a CreateType to define whether or not we are only allowed to * edit, or if we are also allowed to create a new one, etc. * * @param mixed $objParentObject QForm or QPanel which will be using this WordMetaControl * @param integer $intWordId primary key value * @param QMetaControlCreateType $intCreateType rules governing Word object creation - defaults to CreateOrEdit * @return WordMetaControl */ public static function Create($objParentObject, $intWordId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit) { // Attempt to Load from PK Arguments if (strlen($intWordId)) { $objWord = Word::Load($intWordId); // Word was found -- return it! if ($objWord) { return new WordMetaControl($objParentObject, $objWord); } else { if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) { throw new QCallerException('Could not find a Word object with PK arguments: ' . $intWordId); } } // If EditOnly is specified, throw an exception } else { if ($intCreateType == QMetaControlCreateType::EditOnly) { throw new QCallerException('No PK arguments specified'); } } // If we are here, then we need to create a new record return new WordMetaControl($objParentObject, new Word()); }
/** * Override method to perform a property "Get" * This will get the value of $strName * * @param string $strName Name of the property to get * @return mixed */ public function __get($strName) { switch ($strName) { /////////////////// // Member Variables /////////////////// case 'WordStatusLogId': /** * Gets the value for intWordStatusLogId (Read-Only PK) * @return integer */ return $this->intWordStatusLogId; case 'WordId': /** * Gets the value for intWordId (Not Null) * @return integer */ return $this->intWordId; case 'StatusTypeId': /** * Gets the value for intStatusTypeId (Not Null) * @return integer */ return $this->intStatusTypeId; case 'ChangedBy': /** * Gets the value for strChangedBy (Not Null) * @return string */ return $this->strChangedBy; case 'ChangedAt': /** * Gets the value for dttChangedAt (Not Null) * @return QDateTime */ return $this->dttChangedAt; /////////////////// // Member Objects /////////////////// /////////////////// // Member Objects /////////////////// case 'Word': /** * Gets the value for the Word object referenced by intWordId (Not Null) * @return Word */ try { if (!$this->objWord && !is_null($this->intWordId)) { $this->objWord = Word::Load($this->intWordId); } return $this->objWord; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } //////////////////////////// // Virtual Object References (Many to Many and Reverse References) // (If restored via a "Many-to" expansion) //////////////////////////// //////////////////////////// // Virtual Object References (Many to Many and Reverse References) // (If restored via a "Many-to" expansion) //////////////////////////// case '__Restored': return $this->__blnRestored; default: try { return parent::__get($strName); } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } } }
/** * Reload this Word from the database. * @return void */ public function Reload() { // Make sure we are actually Restored from the database if (!$this->__blnRestored) { throw new QCallerException('Cannot call Reload() on a new, unsaved Word object.'); } // Reload the Object $objReloaded = Word::Load($this->intWordId); // Update $this's local variables to match $this->strWord = $objReloaded->strWord; $this->StatusTypeId = $objReloaded->StatusTypeId; $this->intProposalCount = $objReloaded->intProposalCount; $this->dttLastSent = $objReloaded->dttLastSent; }