本文整理汇总了PHP中Attribute::Load方法的典型用法代码示例。如果您正苦于以下问题:PHP Attribute::Load方法的具体用法?PHP Attribute::Load怎么用?PHP Attribute::Load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Attribute
的用法示例。
在下文中一共展示了Attribute::Load方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GetQqNodeForAttributeNode
protected function GetQqNodeForAttributeNode(QQCondition &$objQqCondition = null, &$objQqClauses = null, $strValue)
{
// Get the Attribute object we are trying to query against
$objAttribute = Attribute::Load($this->NodeDetail);
$strAttributeValueTableAlias = 'av' . self::$intJoinCount++;
$objQqClauses[] = QQ::CustomJoin('attribute_value', $strAttributeValueTableAlias, sprintf('%s%s%s.%sperson_id%s = %st0%s.%sid%s AND %s%s%s.%sattribute_id%s = %s', self::GetDatabase()->EscapeIdentifierBegin, $strAttributeValueTableAlias, self::GetDatabase()->EscapeIdentifierEnd, self::GetDatabase()->EscapeIdentifierBegin, self::GetDatabase()->EscapeIdentifierEnd, self::GetDatabase()->EscapeIdentifierBegin, self::GetDatabase()->EscapeIdentifierEnd, self::GetDatabase()->EscapeIdentifierBegin, self::GetDatabase()->EscapeIdentifierEnd, self::GetDatabase()->EscapeIdentifierBegin, $strAttributeValueTableAlias, self::GetDatabase()->EscapeIdentifierEnd, self::GetDatabase()->EscapeIdentifierBegin, self::GetDatabase()->EscapeIdentifierEnd, $objAttribute->Id));
// What is the ATTRIBUTE's type? Figure out the Custom QQ Node based on that
switch ($objAttribute->AttributeDataTypeId) {
case AttributeDataType::Checkbox:
$objQqNode = QQ::CustomNode(sprintf('%s.boolean_value', $strAttributeValueTableAlias));
break;
case AttributeDataType::Date:
$objQqNode = QQ::CustomNode(sprintf('%s.date_value', $strAttributeValueTableAlias));
break;
case AttributeDataType::DateTime:
$objQqNode = QQ::CustomNode(sprintf('%s.datetime_value', $strAttributeValueTableAlias));
break;
case AttributeDataType::Text:
$objQqNode = QQ::CustomNode(sprintf('%s.text_value', $strAttributeValueTableAlias));
break;
case AttributeDataType::ImmutableSingleDropdown:
case AttributeDataType::MutableSingleDropdown:
$objQqNode = QQ::CustomNode(sprintf('%s.single_attribute_option_id', $strAttributeValueTableAlias));
break;
case AttributeDataType::ImmutableMultipleDropdown:
case AttributeDataType::MutableMultipleDropdown:
$strAttributeOptionTableAlias = 'avmaoa' . self::$intJoinCount++;
$objQqClauses[] = QQ::CustomJoin('attributevalue_multipleattributeoption_assn', $strAttributeOptionTableAlias, sprintf("%s.attribute_value_id = %s.id AND %s.attribute_option_id = '%s'", $strAttributeOptionTableAlias, $strAttributeValueTableAlias, $strAttributeOptionTableAlias, $strValue));
$objQqNode = QQ::CustomNode(sprintf('%s.attribute_option_id', $strAttributeOptionTableAlias));
break;
default:
throw new Exception('No Support for Attribute Data Type Id: ' . $objAttribute->AttributeDataTypeId);
}
return $objQqNode;
}
示例2: Create
/**
* 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 AttributeMetaControl
* @param integer $intId primary key value
* @param QMetaControlCreateType $intCreateType rules governing Attribute object creation - defaults to CreateOrEdit
* @return AttributeMetaControl
*/
public static function Create($objParentObject, $intId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit)
{
// Attempt to Load from PK Arguments
if (strlen($intId)) {
$objAttribute = Attribute::Load($intId);
// Attribute was found -- return it!
if ($objAttribute) {
return new AttributeMetaControl($objParentObject, $objAttribute);
} else {
if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) {
throw new QCallerException('Could not find a Attribute object with PK arguments: ' . $intId);
}
}
// 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 AttributeMetaControl($objParentObject, new Attribute());
}
示例3: btnEditAttribute_Click
public function btnEditAttribute_Click($strFormId, $strControlId, $strParameter)
{
$paramArray = explode("_", $strParameter);
// First, remove all children panels from pnlRight
$this->pnlRight->Display = "block";
$this->pnlRight->DisplayStyle = "block";
$this->pnlRight->RemoveChildControls(true);
// Determine where to display the panel
$range = 1;
if ($paramArray[3] < 5) {
$range = 1;
} elseif ($paramArray[3] < 15) {
$range = 2;
} else {
$range = 3;
}
$height = $this->iAttributeCount / $range * 35;
$this->strAttributeHeight = sprintf("-%dpx", $height);
$this->pnlRight->Top = $this->strAttributeHeight;
// Now create a new AttributeEditPanel, setting pnlRight as its parent
// and specifying parent form's "CloseRightPanel" as the method callback
// See the note in _constructor, above, for more information
/*new Vicp_Attributes_Edit($this->pnlRight, null, $this->objPerson,$this->strUrlHashArgument);*/
// Test to see if it works
// Special case for Co-Primary. If co-primary, then ensure there is a date of birth
if ($paramArray[2] == 'Co-Primary' && !$this->objPerson->DateOfBirth) {
$this->lblTitle = new QLabel($this->pnlRight);
$this->lblTitle->HtmlEntities = false;
$this->lblTitle->Text = "You cannot specify a Co-primary email unless the person has a Date Of Birth specified. <br>Please ensure that this is the case before setting this attribute.";
} else {
$this->objAttributeValue = AttributeValue::LoadByAttributeIdPersonId($strParameter, $this->objPerson->Id);
if (!$this->objAttributeValue) {
$this->objAttributeValue = new AttributeValue();
$this->objAttributeValue->AttributeId = $paramArray[0];
$this->objAttributeValue->Person = $this->objPerson;
$this->objAttributeValue->Attribute = Attribute::Load($paramArray[0]);
}
// Determine what to display
$this->lblTitle = new QLabel($this->pnlRight);
$this->lblTitle->Text = $paramArray[2];
if ($paramArray[2] == 'Co-Primary') {
$this->lblTitle->HtmlEntities = false;
$this->lblTitle->Text .= '<br>Please not that the Co-Primary email entered MUST be an existing person in noah.';
}
$this->lblTitle->CssClass = 'attributeLbl';
switch ($paramArray[1]) {
case AttributeDataType::Checkbox:
$this->chkValue = new QRadioButtonList($this->pnlRight);
$this->chkValue->Name = $paramArray[2];
$this->chkValue->Required = true;
$this->chkValue->AddItem('Yes', true, $this->objAttributeValue->BooleanValue === true);
$this->chkValue->AddItem('No', false, $this->objAttributeValue->BooleanValue === false);
break;
case AttributeDataType::Date:
case AttributeDataType::DateTime:
$this->dtxValue = new QDateTimeTextBox($this->pnlRight);
$this->dtxValue->Name = $paramArray[2];
$this->dtxValue->Required = true;
$this->calValue = new QCalendar($this->pnlRight, $this->dtxValue);
$this->dtxValue->RemoveAllActions(QClickEvent::EventName);
if ($this->objAttributeValue->Attribute->AttributeDataTypeId == AttributeDataType::Date) {
$this->dtxValue->Text = $this->objAttributeValue->DateValue ? $this->objAttributeValue->DateValue->ToString() : null;
} else {
$this->dtxValue->Text = $this->objAttributeValue->DatetimeValue ? $this->objAttributeValue->DatetimeValue->ToString() : null;
}
break;
case AttributeDataType::Text:
$this->txtValue = new QTextBox($this->pnlRight);
$this->txtValue->Name = $paramArray[2];
$this->txtValue->Required = true;
$this->txtValue->TextMode = QTextMode::MultiLine;
$this->txtValue->Text = trim($this->objAttributeValue->TextValue);
$this->txtValue->FontNames = QFontFamily::Arial;
$this->txtValue->FontSize = '11px';
$this->txtValue->Width = '380px';
$this->txtValue->Height = '200px';
break;
case AttributeDataType::ImmutableSingleDropdown:
$this->lstValue = new QListBox($this->pnlRight);
$this->lstValue->Name = $paramArray[2];
$this->lstValue->Required = true;
if (!$this->objAttributeValue->SingleAttributeOptionId) {
$this->lstValue->AddItem('- Select One -');
}
foreach ($this->objAttributeValue->Attribute->GetAttributeOptionArray(QQ::OrderBy(QQN::AttributeOption()->Name)) as $objOption) {
$this->lstValue->AddItem($objOption->Name, $objOption->Id, $objOption->Id == $this->objAttributeValue->SingleAttributeOptionId);
}
break;
case AttributeDataType::ImmutableMultipleDropdown:
$this->lstValue = new QListBox($this->pnlRight);
$this->lstValue->Name = $paramArray[2];
$this->lstValue->Required = true;
$this->lstValue->SelectionMode = QSelectionMode::Multiple;
$this->lstValue->Width = '200px';
$this->lstValue->Height = '200px';
$intSelectedIdArray = array();
if ($this->objAttributeValue->Id) {
foreach ($this->objAttributeValue->GetAttributeOptionAsMultipleArray() as $objOption) {
$intSelectedIdArray[$objOption->Id] = $objOption->Id;
}
//.........这里部分代码省略.........
示例4: __get
/**
* 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 'Id':
// Gets the value for intId (Read-Only PK)
// @return integer
return $this->intId;
case 'AttributeId':
// Gets the value for intAttributeId (Not Null)
// @return integer
return $this->intAttributeId;
case 'PersonId':
// Gets the value for intPersonId (Not Null)
// @return integer
return $this->intPersonId;
case 'DateValue':
// Gets the value for dttDateValue
// @return QDateTime
return $this->dttDateValue;
case 'DatetimeValue':
// Gets the value for dttDatetimeValue
// @return QDateTime
return $this->dttDatetimeValue;
case 'TextValue':
// Gets the value for strTextValue
// @return string
return $this->strTextValue;
case 'BooleanValue':
// Gets the value for blnBooleanValue
// @return boolean
return $this->blnBooleanValue;
case 'SingleAttributeOptionId':
// Gets the value for intSingleAttributeOptionId
// @return integer
return $this->intSingleAttributeOptionId;
///////////////////
// Member Objects
///////////////////
///////////////////
// Member Objects
///////////////////
case 'Attribute':
// Gets the value for the Attribute object referenced by intAttributeId (Not Null)
// @return Attribute
try {
if (!$this->objAttribute && !is_null($this->intAttributeId)) {
$this->objAttribute = Attribute::Load($this->intAttributeId);
}
return $this->objAttribute;
} catch (QCallerException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
case 'Person':
// Gets the value for the Person object referenced by intPersonId (Not Null)
// @return Person
try {
if (!$this->objPerson && !is_null($this->intPersonId)) {
$this->objPerson = Person::Load($this->intPersonId);
}
return $this->objPerson;
} catch (QCallerException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
case 'SingleAttributeOption':
// Gets the value for the AttributeOption object referenced by intSingleAttributeOptionId
// @return AttributeOption
try {
if (!$this->objSingleAttributeOption && !is_null($this->intSingleAttributeOptionId)) {
$this->objSingleAttributeOption = AttributeOption::Load($this->intSingleAttributeOptionId);
}
return $this->objSingleAttributeOption;
} 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 '_AttributeOptionAsMultiple':
// Gets the value for the private _objAttributeOptionAsMultiple (Read-Only)
// if set due to an expansion on the attributevalue_multipleattributeoption_assn association table
// @return AttributeOption
return $this->_objAttributeOptionAsMultiple;
//.........这里部分代码省略.........
示例5: Reload
/**
* Reload this Attribute 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 Attribute object.');
}
// Reload the Object
$objReloaded = Attribute::Load($this->intId);
// Update $this's local variables to match
$this->AttributeDataTypeId = $objReloaded->AttributeDataTypeId;
$this->strName = $objReloaded->strName;
}
示例6: __get
/**
* 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 'Id':
// Gets the value for intId (Read-Only PK)
// @return integer
return $this->intId;
case 'AttributeId':
// Gets the value for intAttributeId (Not Null)
// @return integer
return $this->intAttributeId;
case 'Name':
// Gets the value for strName
// @return string
return $this->strName;
///////////////////
// Member Objects
///////////////////
///////////////////
// Member Objects
///////////////////
case 'Attribute':
// Gets the value for the Attribute object referenced by intAttributeId (Not Null)
// @return Attribute
try {
if (!$this->objAttribute && !is_null($this->intAttributeId)) {
$this->objAttribute = Attribute::Load($this->intAttributeId);
}
return $this->objAttribute;
} 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 '_AttributeValueAsMultiple':
// Gets the value for the private _objAttributeValueAsMultiple (Read-Only)
// if set due to an expansion on the attributevalue_multipleattributeoption_assn association table
// @return AttributeValue
return $this->_objAttributeValueAsMultiple;
case '_AttributeValueAsMultipleArray':
// Gets the value for the private _objAttributeValueAsMultipleArray (Read-Only)
// if set due to an ExpandAsArray on the attributevalue_multipleattributeoption_assn association table
// @return AttributeValue[]
return (array) $this->_objAttributeValueAsMultipleArray;
case '_AttributeValueAsSingle':
// Gets the value for the private _objAttributeValueAsSingle (Read-Only)
// if set due to an expansion on the attribute_value.single_attribute_option_id reverse relationship
// @return AttributeValue
return $this->_objAttributeValueAsSingle;
case '_AttributeValueAsSingleArray':
// Gets the value for the private _objAttributeValueAsSingleArray (Read-Only)
// if set due to an ExpandAsArray on the attribute_value.single_attribute_option_id reverse relationship
// @return AttributeValue[]
return (array) $this->_objAttributeValueAsSingleArray;
case '__Restored':
return $this->__blnRestored;
default:
try {
return parent::__get($strName);
} catch (QCallerException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
}
}