當前位置: 首頁>>代碼示例>>PHP>>正文


PHP AttributeValue類代碼示例

本文整理匯總了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}}');
 }
開發者ID:alextravin,項目名稱:yupe,代碼行數:30,代碼來源:m150907_084604_new_attributes.php

示例2: getByID

	public static function getByID($avID) {
		$av = new AttributeValue();
		$av->load($avID);
		if ($av->getAttributeValueID() == $avID) {
			return $av;
		}
	}
開發者ID:notzen,項目名稱:concrete5,代碼行數:7,代碼來源:value.php

示例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');
     }
 }
開發者ID:alcf,項目名稱:chms,代碼行數:25,代碼來源:Vicp_Attributes.class.php

示例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());
 }
開發者ID:Atlis,項目名稱:docker-magento2,代碼行數:8,代碼來源:AttributeValueTest.php

示例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);
 }
開發者ID:inklabs,項目名稱:kommerce-core,代碼行數:11,代碼來源:ProductAttribute.php

示例6: __construct

 public function __construct($pa_value_array = null)
 {
     parent::__construct($pa_value_array);
     if (!DateRangeAttributeValue::$o_tep) {
         DateRangeAttributeValue::$o_tep = new TimeExpressionParser();
     }
 }
開發者ID:samrahman,項目名稱:providence,代碼行數:7,代碼來源:DateRangeAttributeValue.php

示例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";
}
開發者ID:alcf,項目名稱:chms,代碼行數:26,代碼來源:acs-wsm-import.cli.php

示例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;
 }
開發者ID:nico13051995,項目名稱:IntITA,代碼行數:29,代碼來源:TeacherHelper.php

示例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);
     }
 }
開發者ID:JeCat,項目名稱:framework,代碼行數:11,代碼來源:Tag.php

示例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;
 }
開發者ID:booko,項目名稱:pasteque-server,代碼行數:11,代碼來源:AttributesService.php

示例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();
 }
開發者ID:yupe,項目名稱:yupe,代碼行數:14,代碼來源:AttributeBackendController.php

示例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) . '
			');
    }
開發者ID:alcf,項目名稱:chms,代碼行數:25,代碼來源:PersonGen.class.php

示例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);
 }
開發者ID:alcf,項目名稱:chms,代碼行數:35,代碼來源:AttributeValueDataGridGen.class.php

示例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();
//.........這裏部分代碼省略.........
開發者ID:alcf,項目名稱:chms,代碼行數:101,代碼來源:Vicp_Attributes_Edit.class.php

示例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...'));
             }
         }
     }
 }
開發者ID:syrexby,項目名稱:domovoishop.by,代碼行數:17,代碼來源:ProductBackendController.php


注:本文中的AttributeValue類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。