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


PHP AttributeValue::model方法代碼示例

本文整理匯總了PHP中AttributeValue::model方法的典型用法代碼示例。如果您正苦於以下問題:PHP AttributeValue::model方法的具體用法?PHP AttributeValue::model怎麽用?PHP AttributeValue::model使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在AttributeValue的用法示例。


在下文中一共展示了AttributeValue::model方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: 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

示例2: 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

示例3: 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

示例4: saveTypeAttributes

 /**
  * @param array $attributes
  * @return bool
  */
 public function saveTypeAttributes(array $attributes)
 {
     $transaction = Yii::app()->getDb()->beginTransaction();
     try {
         foreach ($attributes as $attribute => $value) {
             if (null === $value) {
                 continue;
             }
             $model = AttributeValue::model()->find('product_id = :product AND attribute_id = :attribute', [':product' => $this->id, ':attribute' => $attribute]);
             //множественные значения
             if (is_array($value)) {
                 AttributeValue::model()->deleteAll('product_id = :product AND attribute_id = :attribute', [':product' => $this->id, ':attribute' => $attribute]);
                 foreach ($value as $val) {
                     $model = new AttributeValue();
                     if (false === $model->store($attribute, $val, $this)) {
                         throw new InvalidArgumentException('Error store attribute!');
                     }
                 }
             } else {
                 $model = $model ?: new AttributeValue();
                 if (false === $model->store($attribute, $value, $this)) {
                     throw new InvalidArgumentException('Error store attribute!');
                 }
             }
         }
         $transaction->commit();
         return true;
     } catch (Exception $e) {
         $transaction->rollback();
         return false;
     }
 }
開發者ID:yupe,項目名稱:yupe,代碼行數:36,代碼來源:Product.php

示例5: attribute

 /**
  * @param $attribute
  * @param null $default
  * @return bool|float|int|null|string
  */
 public function attribute($attribute, $default = null)
 {
     if ($this->getIsNewRecord()) {
         return null;
     }
     //@TODO переделать на получение в 1 запрос
     $model = AttributeValue::model()->with('attribute')->find('product_id = :product AND attribute_id = :attribute', [':product' => $this->id, ':attribute' => $attribute->id]);
     if (null === $model) {
         return null;
     }
     return $model->value($default);
 }
開發者ID:alextravin,項目名稱:yupe,代碼行數:17,代碼來源:Product.php


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