本文整理汇总了PHP中AttributeValue类的典型用法代码示例。如果您正苦于以下问题:PHP AttributeValue类的具体用法?PHP AttributeValue怎么用?PHP AttributeValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AttributeValue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: safeUp
public function safeUp()
{
$this->createTable('{{store_product_attribute_value}}', ['id' => 'pk', 'product_id' => 'INTEGER NOT NULL', 'attribute_id' => 'INTEGER NOT NULL', 'number_value' => 'REAL', 'string_value' => 'VARCHAR(250)', 'text_value' => 'TEXT', 'option_value' => 'INTEGER', 'create_time' => 'DATETIME'], $this->getOptions());
//fk
$this->addForeignKey('{{fk_product_attribute_product}}', '{{store_product_attribute_value}}', 'product_id', '{{store_product}}', 'id', 'CASCADE');
$this->addForeignKey('{{fk_product_attribute_attribute}}', '{{store_product_attribute_value}}', 'attribute_id', '{{store_attribute}}', 'id', 'CASCADE');
$this->addForeignKey('{{fk_product_attribute_option}}', '{{store_product_attribute_value}}', 'option_value', '{{store_attribute_option}}', 'id', 'CASCADE');
//ix
$this->createIndex('{{ix_product_attribute_number_value}}', '{{store_product_attribute_value}}', 'number_value');
$this->createIndex('{{ix_product_attribute_string_value}}', '{{store_product_attribute_value}}', 'string_value');
//перенести аттрибуты
$attributes = Yii::app()->getDb()->createCommand('SELECT * FROM {{store_product_attribute_eav}}')->queryAll();
$modelsAttr = [];
foreach ($attributes as $attribute) {
$product = Product::model()->findByPk($attribute['product_id']);
if (null === $product) {
continue;
}
if (!isset($modelsAttr[$attribute['attribute']])) {
$model = Attribute::model()->find('name = :name', [':name' => $attribute['attribute']]);
if (null === $model) {
continue;
}
$modelsAttr[$attribute['attribute']] = $model;
}
$value = new AttributeValue();
$value->store($modelsAttr[$attribute['attribute']]->id, $attribute['value'], $product);
}
$this->dropTable('{{store_product_attribute_eav}}');
}
示例2: getByID
public static function getByID($avID) {
$av = new AttributeValue();
$av->load($avID);
if ($av->getAttributeValueID() == $avID) {
return $av;
}
}
示例3: RenderValue
public function RenderValue(AttributeValue $objValue)
{
switch ($objValue->Attribute->AttributeDataTypeId) {
case AttributeDataType::Text:
return QApplication::HtmlEntities($objValue->TextValue);
case AttributeDataType::Checkbox:
return $objValue->BooleanValue ? 'Yes' : 'No';
case AttributeDataType::Date:
return $objValue->DateValue->ToString('MMMM D, YYYY');
case AttributeDataType::DateTime:
return $objValue->DatetimeValue->ToString('MMMM D, YYYY') . ' at ' . $objValue->DatetimeValue->ToString('h:mmz');
case AttributeDataType::ImmutableSingleDropdown:
case AttributeDataType::MutableSingleDropdown:
return $objValue->SingleAttributeOption != null ? QApplication::HtmlEntities($objValue->SingleAttributeOption->Name) : ' ';
case AttributeDataType::ImmutableMultipleDropdown:
case AttributeDataType::MutableMultipleDropdown:
$strArray = array();
foreach ($objValue->GetAttributeOptionAsMultipleArray(QQ::OrderBy(QQN::AttributeOption()->Name)) as $objOption) {
$strArray[] = '• ' . QApplication::HtmlEntities($objOption->Name);
}
return implode('<br/>', $strArray);
default:
throw new Exception('Unhandled Attribute Data Type');
}
}
示例4: testConstructorAndGetters
public function testConstructorAndGetters()
{
$helper = new \Magento\TestFramework\Helper\ObjectManager($this);
$attributeBuilder = $helper->getObject('\\Magento\\Framework\\Service\\Data\\Eav\\AttributeValueBuilder')->setAttributeCode(self::ATTRIBUTE_CODE)->setValue(self::VALUE);
$attribute = new AttributeValue($attributeBuilder);
$this->assertSame(self::ATTRIBUTE_CODE, $attribute->getAttributeCode());
$this->assertSame(self::VALUE, $attribute->getValue());
}
示例5: __construct
public function __construct(Product $product, Attribute $attribute, AttributeValue $attributeValue)
{
$this->setId();
$this->setCreated();
$this->product = $product;
$this->attribute = $attribute;
$this->attributeValue = $attributeValue;
$product->addProductAttribute($this);
$attribute->addProductAttribute($this);
$attributeValue->addProductAttribute($this);
}
示例6: __construct
public function __construct($pa_value_array = null)
{
parent::__construct($pa_value_array);
if (!DateRangeAttributeValue::$o_tep) {
DateRangeAttributeValue::$o_tep = new TimeExpressionParser();
}
}
示例7: CreateGroupParticipations
function CreateGroupParticipations(mysqli $objAcsDatabase, Group $objGroup, GroupRole $objRole, $intAcsGroupId, $intAcsReserveId)
{
print "Adding for Group: " . $objGroup->Name . "\r\n ";
if ($intAcsReserveId) {
$objResult = $objAcsDatabase->query(sprintf('select * from awgrrost where groupid=%s AND reserveid1=%s', $intAcsGroupId, $intAcsReserveId));
} else {
$objResult = $objAcsDatabase->query(sprintf('select * from awgrrost where groupid=%s', $intAcsGroupId));
}
while ($objRow = $objResult->fetch_array()) {
$objAttributeValueArray = AttributeValue::QueryArray(QQ::AndCondition(QQ::Equal(QQN::AttributeValue()->AttributeId, 2), QQ::Equal(QQN::AttributeValue()->TextValue, $objRow['indvid'])));
if (count($objAttributeValueArray) != 1) {
printf("Issue with awgrrost.pkid of %s - IndvId %s for Group %s - AVCount of %s\r\n", $objRow['pkid'], $objRow['indvid'], $objGroup->Name, count($objAttributeValueArray));
} else {
$objPerson = $objAttributeValueArray[0]->Person;
$dttStartDate = new QDateTime($objRow['dateadded']);
if ($objRow['dateremoved']) {
$dttEndDate = new QDateTime($objRow['dateremoved']);
} else {
$dttEndDate = null;
}
$objGroup->AddPerson($objPerson, $objRole->Id, $dttStartDate, $dttEndDate);
print "*";
}
}
print "\r\n Done.\r\n\r\n";
}
示例8: getTeacherAttributeValue
public static function getTeacherAttributeValue($teacher, $attribute){
$result = '';
switch($attribute){
case '1': //capacity
$result = AttributeValue::model()->findByAttributes(array('teacher'=>$teacher, 'attribute'=>$attribute))->value;
break;
case '2': //trainer's students
$result = TeacherHelper::getTrainerStudents($teacher);
break;
case '3': //consultant_modules
$result = TeacherHelper::getConsultantModules($teacher);
break;
case '4':// leader's projects
$result = TeacherHelper::getLeaderProjects($teacher);
break;
case '6'://leader's modules
$result = TeacherHelper::getLeaderModules($teacher);
break;
case '7'://author's modules
$result = TeacherHelper::getLeaderModules($teacher);
break;
case '8'://leader's capacity
$result = AttributeValue::model()->findByAttributes(array('teacher'=>$teacher, 'attribute'=>$attribute))->value;
break;
default:
$result = AttributeValue::model()->findByAttributes(array('teacher'=>$teacher, 'attribute'=>$attribute))->value;
}
return $result;
}
示例9: add
public function add($aChild, $sName = null, $bTakeover = true)
{
if ($aChild instanceof Macro) {
$aAttrVal = new AttributeValue(null, '', $aChild->position(), $aChild->line());
$aAttrVal->setEndPosition($aChild->endPosition());
$aAttrVal->add($aChild);
$this->attributes()->add($aAttrVal);
$aAttrVal->setParent($this);
$aChild->setParent($this);
}
}
示例10: buildDBAttr
private static function buildDBAttr($dbAttr, $pdo)
{
$attr = Attribute::__build($dbAttr['ID'], $dbAttr['NAME'], null);
$valstmt = $pdo->prepare("SELECT * FROM ATTRIBUTEVALUE WHERE " . "ATTRIBUTE_ID = :id ORDER BY VALUE");
$valstmt->execute(array(':id' => $dbAttr['ID']));
while ($dbVal = $valstmt->fetch()) {
$val = AttributeValue::__build($dbVal['ID'], $dbVal['VALUE']);
$attr->addValue($val);
}
return $attr;
}
示例11: actionDeleteFile
public function actionDeleteFile()
{
if (!Yii::app()->getRequest()->getIsPostRequest()) {
throw new CHttpException();
}
$product = (int) Yii::app()->getRequest()->getPost('product');
$attribute = (int) Yii::app()->getRequest()->getPost('attribute');
$model = AttributeValue::model()->find('product_id = :product AND attribute_id = :attribute', [':product' => $product, ':attribute' => $attribute]);
if (null === $model || null === $model->getFilePath()) {
Yii::app()->ajax->success();
}
$model->delete();
Yii::app()->ajax->success();
}
示例12: DeleteAllAttributeValues
/**
* Deletes all associated AttributeValues
* @return void
*/
public function DeleteAllAttributeValues()
{
if (is_null($this->intId)) {
throw new QUndefinedPrimaryKeyException('Unable to call UnassociateAttributeValue on this unsaved Person.');
}
// Get the Database Object for this Class
$objDatabase = Person::GetDatabase();
// Journaling
if ($objDatabase->JournalingDatabase) {
foreach (AttributeValue::LoadArrayByPersonId($this->intId) as $objAttributeValue) {
$objAttributeValue->Journal('DELETE');
}
}
// Perform the SQL Query
$objDatabase->NonQuery('
DELETE FROM
`attribute_value`
WHERE
`person_id` = ' . $objDatabase->SqlVariable($this->intId) . '
');
}
示例13: MetaDataBinder
/**
* Main utility method to aid with data binding. It is used by the default BindAllRows() databinder but
* could and should be used by any custom databind methods that would be used for instances of this
* MetaDataGrid, by simply passing in a custom QQCondition and/or QQClause.
*
* If a paginator is set on this DataBinder, it will use it. If not, then no pagination will be used.
* It will also perform any sorting (if applicable).
*
* @param QQCondition $objConditions override the default condition of QQ::All() to the query, itself
* @param QQClause[] $objOptionalClauses additional optional QQClause object or array of QQClause objects for the query
* @return void
*/
public function MetaDataBinder(QQCondition $objCondition = null, $objOptionalClauses = null)
{
// Setup input parameters to default values if none passed in
if (!$objCondition) {
$objCondition = QQ::All();
}
$objClauses = $objOptionalClauses ? $objOptionalClauses : array();
// We need to first set the TotalItemCount, which will affect the calcuation of LimitClause below
if ($this->Paginator) {
$this->TotalItemCount = AttributeValue::QueryCount($objCondition, $objClauses);
}
// If a column is selected to be sorted, and if that column has a OrderByClause set on it, then let's add
// the OrderByClause to the $objClauses array
if ($objClause = $this->OrderByClause) {
array_push($objClauses, $objClause);
}
// Add the LimitClause information, as well
if ($objClause = $this->LimitClause) {
array_push($objClauses, $objClause);
}
// Set the DataSource to be a Query result from AttributeValue, given the clauses above
$this->DataSource = AttributeValue::QueryArray($objCondition, $objClauses);
}
示例14: SetupPanel
protected function SetupPanel()
{
$this->objAttributeValue = AttributeValue::LoadByAttributeIdPersonId($this->strUrlHashArgument, $this->objPerson->Id);
if (!$this->objAttributeValue) {
$this->objAttributeValue = new AttributeValue();
$this->objAttributeValue->AttributeId = $this->strUrlHashArgument;
$this->objAttributeValue->Person = $this->objPerson;
} else {
$this->btnDelete = new QLinkButton($this);
$this->btnDelete->Text = 'Delete';
$this->btnDelete->CssClass = 'delete';
$this->btnDelete->AddAction(new QClickEvent(), new QConfirmAction('Are you SURE you want to DELETE this attribute?'));
$this->btnDelete->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnDelete_Click'));
$this->btnDelete->AddAction(new QClickEvent(), new QTerminateAction());
}
switch ($this->objAttributeValue->Attribute->AttributeDataTypeId) {
case AttributeDataType::Checkbox:
$this->chkValue = new QRadioButtonList($this);
$this->chkValue->Name = $this->objAttributeValue->Attribute->Name;
$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);
$this->dtxValue->Name = $this->objAttributeValue->Attribute->Name;
$this->dtxValue->Required = true;
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;
}
$this->calValue = new QCalendar($this, $this->dtxValue);
$this->dtxValue->RemoveAllActions(QClickEvent::EventName);
break;
case AttributeDataType::Text:
$this->txtValue = new QTextBox($this);
$this->txtValue->Name = $this->objAttributeValue->Attribute->Name;
$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 = '400px';
$this->txtValue->Height = '200px';
break;
case AttributeDataType::ImmutableSingleDropdown:
$this->lstValue = new QListBox($this);
$this->lstValue->Name = $this->objAttributeValue->Attribute->Name;
$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);
$this->lstValue->Name = $this->objAttributeValue->Attribute->Name;
$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;
}
}
foreach ($this->objAttributeValue->Attribute->GetAttributeOptionArray(QQ::OrderBy(QQN::AttributeOption()->Name)) as $objOption) {
$this->lstValue->AddItem($objOption->Name, $objOption->Id, array_key_exists($objOption->Id, $intSelectedIdArray));
}
break;
case AttributeDataType::MutableSingleDropdown:
$this->lstValue = new QListBox($this);
$this->lstValue->Name = $this->objAttributeValue->Attribute->Name;
$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);
}
$this->lstValue->AddItem('- Other... -', -1);
$this->txtAddItem = new QTextBox($this);
$this->txtAddItem->Name = 'Add a Value';
$this->txtAddItem->Visible = false;
$this->lstValue->AddAction(new QChangeEvent(), new QAjaxControlAction($this, 'lstValue_Change'));
$this->txtAddItem->AddAction(new QEnterKeyEvent(), new QTerminateAction());
break;
case AttributeDataType::MutableMultipleDropdown:
$this->lstValue = new QListBox($this);
$this->lstValue->Name = $this->objAttributeValue->Attribute->Name;
$this->lstValue->Required = true;
$this->lstValue->SelectionMode = QSelectionMode::Multiple;
$this->lstValue->Width = '200px';
$this->lstValue->Height = '200px';
$intSelectedIdArray = array();
//.........这里部分代码省略.........
示例15: uploadAttributesFiles
/**
* @param $model
*/
protected function uploadAttributesFiles($model)
{
if (!empty($_FILES['Attribute']['name'])) {
foreach ($_FILES['Attribute']['name'] as $key => $file) {
$value = AttributeValue::model()->find('product_id = :product AND attribute_id = :attribute', [':product' => $model->id, ':attribute' => $key]);
$value = $value ?: new AttributeValue();
$value->setAttributes(['product_id' => $model->id, 'attribute_id' => $key]);
$value->addFileInstanceName('Attribute[' . $key . '][name]');
if (false === $value->save()) {
Yii::app()->getUser()->setFlash(\yupe\widgets\YFlashMessages::ERROR_MESSAGE, Yii::t('StoreModule.store', 'Error uploading some files...'));
}
}
}
}